def __init__(self, nu_0=None, S_0=None, M_0=None, K_0=None, affine=False, A=None, sigma=None): self.affine = affine self.diag_sigma = self._check_shapes(A, sigma, nu_0, S_0, M_0, K_0) self.A = A if self.diag_sigma: self.sigma = np.diag(sigma) self.dsigma = sigma else: self.sigma = sigma self.dsigma = None have_hypers = not any_none(nu_0, S_0, M_0, K_0) if have_hypers: self.natural_hypparam = self.mf_natural_hypparam = \ self._standard_to_natural(nu_0,S_0,M_0,K_0) if A is sigma is None and have_hypers: self.resample() # initialize from prior
def __init__( self, nu_0=None,S_0=None,M_0=None,K_0=None, affine=False, A=None,sigma=None): self.affine = affine self.diag_sigma = self._check_shapes(A, sigma, nu_0, S_0, M_0, K_0) self.A = A if self.diag_sigma: self.sigma = np.diag(sigma) self.dsigma = sigma else: self.sigma = sigma self.dsigma = None have_hypers = not any_none(nu_0,S_0,M_0,K_0) if have_hypers: self.natural_hypparam = self.mf_natural_hypparam = \ self._standard_to_natural(nu_0,S_0,M_0,K_0) if A is sigma is None and have_hypers: self.resample() # initialize from prior
def __init__( self,low=None,high=None, x_m_low=None,alpha_low=None,x_m_high=None,alpha_high=None): self.low = low self.high = high self.x_m_low = x_m_low self.alpha_low = alpha_low self.x_m_high = x_m_high self.alpha_high = alpha_high have_hypers = not any_none(x_m_low,alpha_low,x_m_high,alpha_high) if low is high is None and have_hypers: self.resample() # initialize from prior
def __init__( self, nu_0=None,S_0=None,M_0=None,K_0=None, affine=False, A=None,sigma=None): self.affine = affine self.A = A self.sigma = sigma have_hypers = not any_none(nu_0,S_0,M_0,K_0) if have_hypers: self.natural_hypparam = self._standard_to_natural(nu_0,S_0,M_0,K_0) if A is sigma is None and have_hypers: self.resample() # initialize from prior
def __init__(self, D_out, D_in, mu_0=None, Sigma_0=None, alpha_0=3.0, beta_0=2.0, A=None, sigmasq=None, niter=1): self._D_out = D_out self._D_in = D_in self.A = A self.sigmasq_flat = sigmasq self.affine = False # We do not yet support affine mu_0 = np.zeros(D_in) if mu_0 is None else mu_0 Sigma_0 = np.eye(D_in) if Sigma_0 is None else Sigma_0 assert mu_0.shape == (D_in, ) assert Sigma_0.shape == (D_in, D_in) self.h_0 = np.linalg.solve(Sigma_0, mu_0) self.J_0 = np.linalg.inv(Sigma_0) self.alpha_0 = alpha_0 self.beta_0 = beta_0 self.niter = niter if any_none(A, sigmasq): self.A = np.zeros((D_out, D_in)) self.sigmasq_flat = np.ones((D_out, )) self.resample(data=None) # initialize from prior # Store the natural parameters and expose the standard versions as properties self.mf_J_A = np.array([self.J_0.copy() for _ in range(D_out)]) # Initializing with mean zero is pathological. Break symmetry by starting with sampled A. # self.mf_h_A = np.array([self.h_0.copy() for _ in range(D_out)]) self.mf_h_A = np.array( [Jd.dot(Ad) for Jd, Ad in zip(self.mf_J_A, self.A)]) self.mf_alpha = self.alpha_0 * np.ones(D_out) self.mf_beta = self.alpha_0 * self.sigmasq_flat # Cache the standard parameters for A as well self._mf_A_cache = {}
def __init__(self, low=None, high=None, x_m_low=None, alpha_low=None, x_m_high=None, alpha_high=None): self.low = low self.high = high self.x_m_low = x_m_low self.alpha_low = alpha_low self.x_m_high = x_m_high self.alpha_high = alpha_high have_hypers = not any_none(x_m_low, alpha_low, x_m_high, alpha_high) if low is high is None and have_hypers: self.resample() # initialize from prior
def __init__(self, D_out, D_in, mu_0=None, Sigma_0=None, alpha_0=3.0, beta_0=2.0, A=None, sigmasq=None, niter=1): self._D_out = D_out self._D_in = D_in self.A = A self.sigmasq_flat = sigmasq self.affine = False # We do not yet support affine mu_0 = np.zeros(D_in) if mu_0 is None else mu_0 Sigma_0 = np.eye(D_in) if Sigma_0 is None else Sigma_0 assert mu_0.shape == (D_in,) assert Sigma_0.shape == (D_in, D_in) self.h_0 = np.linalg.solve(Sigma_0, mu_0) self.J_0 = np.linalg.inv(Sigma_0) self.alpha_0 = alpha_0 self.beta_0 = beta_0 self.niter = niter if any_none(A, sigmasq): self.A = np.zeros((D_out, D_in)) self.sigmasq_flat = np.ones((D_out,)) self.resample(data=None) # initialize from prior # Store the natural parameters and expose the standard versions as properties self.mf_J_A = np.array([self.J_0.copy() for _ in range(D_out)]) # Initializing with mean zero is pathological. Break symmetry by starting with sampled A. # self.mf_h_A = np.array([self.h_0.copy() for _ in range(D_out)]) self.mf_h_A = np.array([Jd.dot(Ad) for Jd,Ad in zip(self.mf_J_A, self.A)]) self.mf_alpha = self.alpha_0 * np.ones(D_out) self.mf_beta = self.alpha_0 * self.sigmasq_flat # Cache the standard parameters for A as well self._mf_A_cache = {}