I implemented a probabilistic matrix factorization model (R = U'V
) following the example in Edward's repo:
# data
U_true = np.random.randn(D, N)
V_true = np.random.randn(D, M)
R_true = np.dot(np.transpose(U_true), V_true) + np.random.normal(0, 0.1, size=(N, M))
# model
I = tf.placeholder(tf.float32, [N, M])
U = Normal(loc=tf.zeros([D, N]), scale=tf.ones([D, N]))
V = Normal(loc=tf.zeros([D, M]), scale=tf.ones([D, M]))
R = Normal(loc=tf.matmul(tf.transpose(U), V), scale=tf.ones([N, M]))
I get a good performance when predicting the data in matrix R
. However, when I evaluate the inferred traits in U
and V
, the error varies a lot and can get very high.
I tried with a latent space of small dimension (e.g. 2) and checked if latent traits weren't simply permuted. They sometimes get permuted but even after realigning them the error is still significant.
To throw some numbers: for a synthetic R
matrix generated from U
and V
both normally distributed (mean 0 and variance 1), I can achieve a mean absolute error of 0.003 on R
, but on U
and V
it's usually around 0.5.
I know this model is symmetric, but I am not sure about the implications. I would like to ask:
- Is it actually possible to guarantee the recovery of the original latent traits in some way?
- If so, how could it be achieved, preferably using Edward?