コード例 #1
0
    def _meanfieldupdate_sigma(self, stats, prob=1.0, stepsize=1.0):
        E_ysq, E_yxT, E_xxT, E_n = stats / prob
        E_A, E_AAT, _, _ = self.mf_expectations

        alpha = self.alpha_0 + E_n / 2.0

        beta = self.beta_0
        beta += 0.5 * E_ysq
        beta += -1.0 * np.sum(E_yxT * E_A, axis=1)
        beta += 0.5 * np.sum(E_AAT * E_xxT, axis=(1, 2))

        # Set the invgamma meanfield parameters
        self.mf_alpha = update_param(self.mf_alpha, alpha, stepsize)
        self.mf_beta = update_param(self.mf_beta, beta, stepsize)
コード例 #2
0
ファイル: regression.py プロジェクト: mattjj/pybasicbayes
    def _meanfieldupdate_sigma(self, stats, prob=1.0, stepsize=1.0):
        E_ysq, E_yxT, E_xxT, E_n = stats / prob
        E_A, E_AAT, _, _ = self.mf_expectations

        alpha = self.alpha_0 + E_n / 2.0

        beta = self.beta_0
        beta += 0.5 * E_ysq
        beta += -1.0 * np.sum(E_yxT * E_A, axis=1)
        beta += 0.5 * np.sum(E_AAT * E_xxT, axis=(1,2))

        # Set the invgamma meanfield parameters
        self.mf_alpha = update_param(self.mf_alpha, alpha, stepsize)
        self.mf_beta = update_param(self.mf_beta, beta, stepsize)
コード例 #3
0
    def _meanfieldupdate_A(self, stats, prob=1.0, stepsize=1.0):
        E_sigmasq_inv = self.mf_alpha / self.mf_beta
        _, E_yxT, E_xxT, _ = stats / prob

        # Update statistics each row of A
        for d in range(self.D_out):
            Jd = self.J_0 + (E_xxT[d] * E_sigmasq_inv[d])
            hd = self.h_0 + (E_yxT[d] * E_sigmasq_inv[d])

            # Update the mean field natural parameters
            self.mf_J_A[d] = update_param(self.mf_J_A[d], Jd, stepsize)
            self.mf_h_A[d] = update_param(self.mf_h_A[d], hd, stepsize)

        # Clear the cache
        self._mf_A_cache = {}
コード例 #4
0
ファイル: regression.py プロジェクト: mattjj/pybasicbayes
    def _meanfieldupdate_A(self, stats, prob=1.0, stepsize=1.0):
        E_sigmasq_inv = self.mf_alpha / self.mf_beta
        _, E_yxT, E_xxT, _ = stats  / prob

        # Update statistics each row of A
        for d in range(self.D_out):
            Jd = self.J_0 + (E_xxT[d] * E_sigmasq_inv[d])
            hd = self.h_0 + (E_yxT[d] * E_sigmasq_inv[d])

            # Update the mean field natural parameters
            self.mf_J_A[d] = update_param(self.mf_J_A[d], Jd, stepsize)
            self.mf_h_A[d] = update_param(self.mf_h_A[d], hd, stepsize)

        # Clear the cache
        self._mf_A_cache = {}