Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Bug in MatrixNormal.sample #3585
If one of the matrix parameters is a random variable, then MatrixNormal.sample runs into shape errors because it might be passed an array of col or row matrices instead of just one.
import numpy as np import pymc3 as pm K = 3 D = 15 mu_0 = np.zeros((D,K)) lambd = 1.0 with pm.Model() as model: sd_dist = pm.HalfCauchy.dist(beta=2.5) packedL = pm.LKJCholeskyCov(f"packedL",eta=2, n=D, sd_dist=sd_dist) L = pm.expand_packed_triangular(D, packedL, lower=True) Sigma = pm.Deterministic(f"Sigma", L.dot(L.T)) # D x D covariance mu = pm.MatrixNormal( f"mu", mu=mu_0, rowcov=(1 / lambd) * Sigma, colcov = np.eye(K), shape=(D,K)) prior = pm.sample_prior_predictive(2)
In this example
Originally reported by calvinm on discord: