laura posted on 03-17-2009 11:15 AM
I am trying to do inference in batches using probabilistic submodels with shared variables.
I implemented an LDA style topic model. Now I want to process batches of documents to learn topic-characteristic word-distributions (p(word | topic) a.k.a. phi) that explain the whole document collection well. phi is a multinomial parameter drawn from a
symmetric Dirichlet distribution we assume as given.
Since the number of topics is unknown during model compilation, I tried to create an array of shared variables (to be precise a
SharedVariableArray) for maintaining the messages of phi.
I am stuck in constructing this SharedVariable array...
The documentation says
public static SharedVariableArray<DomainType> Random<DistributionArrayType>(
Range range,
DistributionArrayType prior
)
I assume that in my case the DomainType is Vector, and the DistributionType is probably a DistributionRefArray with T Dirichlet.
The following code compiles
let prior = new DistributionRefArray<Dirichlet,Vector>((RandomDirichletArray cRange.SizeAsInt vNum):Dirichlet[])
let phiShared = SharedVariable<Vector>.Random<DistributionRefArray<Dirichlet,Vector>>(cRange,prior )
let phi = phiShared.GetCopyFor(model)
But I get an error message complaining
MessageTransform failed with 4 error(s) and 0 warning(s):
System.Double is not an array type.
System.Double is not an array type. in
Vector sharedVector__DistributionRefArrayLtDirichlet_VectorGt0_cRange_cond_f_uRange__sRange__marginal
System.Double is not an array type.
System.Double is not an array type. in
Vector sharedVector__DistributionRefArrayLtDirichlet_VectorGt0_cRange_cond_f_uRange__sRange_
Argument type could not be found for argument 'Def' in
sharedVector__DistributionRefArrayLtDirichlet_VectorGt0_cRange_cond_f_uRange__sRange__uses = Factor.ReplicateWithMarginal<Vector>(sharedVector__DistributionRefArrayLtDirichlet_VectorGt0_cRange_cond_f_uRange__sRange_, sharedVector__DistributionRefArrayLtDirichlet_VectorGt0_cRange_cond_f_uRange__sRange__marginal)
Argument type could not be found for argument 'enterOne' in
sharedVector__DistributionRefArrayLtDirichlet_VectorGt0_cRange_cond_f_uRange__sRange_ = Gate.EnterOne<Vector>(f_cases_rep0_uses[0][cRange], sharedVector__DistributionRefArrayLtDirichlet_VectorGt0_rep0_rep0[sRange][cRange], cRange)
Any ideas?
Laura