shakey posted on 11-21-2009 7:42 AM
I want to test the lda model on new documents, I take the method on the baysian point machine example:
setting the phi in the test model to the posterior phi from the training model. However, I always get errors indicating violation of type constrain. Can anyone give me some help on this ? It seems SharedVariable is another kind of
solution, but I cannot get it right either.
part of the code:
post_phi=engine.Infer[DistributionRefArray[Dirichlet,Vector]](phi)
test_post_phi=Variable[Vector].Random[DistributionRefArray[Dirichlet,Vector]](post_phi )
with (Variable.ForEach(test_CorpusSize)) as forBlock :
with (Variable.ForEach(test_DocSize)) as forBlock :
test_Z[test_CorpusSize][test_DocSize] = Variable.Discrete(test_theta[test_CorpusSize]).Attrib( ValueRange(TopicsNum))
with (Variable.Switch(test_Z[test_CorpusSize][test_DocSize])) as swBlock :
test_W[test_CorpusSize][test_DocSize] = Variable.Discrete(test_post_phi[ test_Z[test_CorpusSize][ test_DocSize] ])