Hi,
I was going over the factor analysis example and wanted try a model. For this, I wanted to use an independent and identically sampled normal matrix and wanted to normalize its columns to have norm 1. When I try to sample from the model, I get an error, I don’t know what is wrong. What do you think:
estimated_K = 5
coords = {'estimated K': np.arange(estimated_K), 'D': np.arange(D), 'N': np.arange(N)}
with pm.Model(coords=coords) as model1:
sigma0 = pm.Exponential('sigma0', lam=1, dims=['estimated K'])
sigma1 = pm.HalfNormal('sigma1')
sigma2 = pm.HalfNormal('sigma2')
U = pm.Normal('U', 0, 1, dims=['N', 'estimated K'])
column_norm_U = pt.nlinalg.norm(U, axis=0)
normalized_U = pm.Deterministic('normalized U', U/column_norm_U)
V = pm.Normal('V', 0, 1, dims=['estimated K', 'estimated K'])
column_norm_V = pt.nlinalg.norm(V, axis=0)
normalized_V = pm.Deterministic('normalized V', V/column_norm_V)
F = pm.Deterministic('F', pm.math.dot(normalized_U*sigma0, normalized_V.T))
W = pm.Normal('W', mu=0, sigma=sigma1, dims=['estimated K', 'D'])
y = pm.Normal('y', mu=F @ W, sigma=sigma2, observed=observed_y, dims=['N', 'D'])
pm.model_to_graphviz(model1)
TypeError: Real.grad illegally returned an integer-valued variable. (Input index 0, dtype complex128)