def symbolic_logq_not_scaled(self): z0 = self.symbolic_initial std = rho2sigma(self.rho) logdet = at.log(std) quaddist = -0.5 * z0**2 - at.log((2 * np.pi)**0.5) logq = quaddist - logdet return logq.sum(range(1, logq.ndim))
def L(self): if self.batched: L = at.zeros((self.ddim, self.ddim, self.bdim)) L = at.set_subtensor(L[self.tril_indices], self.params_dict["L_tril"].T) L = L.dimshuffle(2, 0, 1) else: L = at.zeros((self.ddim, self.ddim)) L = at.set_subtensor(L[self.tril_indices], self.params_dict["L_tril"]) Ld = L[..., np.arange(self.ddim), np.arange(self.ddim)] L = at.set_subtensor(Ld, rho2sigma(Ld)) return L
def std(self): return rho2sigma(self.rho)
def cov(self): var = rho2sigma(self.rho)**2 if self.batched: return batched_diag(var) else: return at.diag(var)
def symbolic_logq_not_scaled(self): z0 = self.symbolic_initial std = rho2sigma(self.rho) logdet = at.log(std) logq = pm.Normal.dist().logp(z0) - logdet return logq.sum(range(1, logq.ndim))
def cov(self): var = rho2sigma(self.rho) ** 2 return at.diag(var)
def L(self): L = at.zeros((self.ddim, self.ddim)) L = at.set_subtensor(L[self.tril_indices], self.params_dict["L_tril"]) Ld = L[..., np.arange(self.ddim), np.arange(self.ddim)] L = at.set_subtensor(Ld, rho2sigma(Ld)) return L
def __init__(self, rho=None, **kwargs): super().__init__(**kwargs) rho = self.add_param(rho, "rho") self.scale = rho2sigma(rho) self.shared_params = dict(rho=rho)