locked
How do I create SharedVariable Arrays for Dirichlet distributed r.v.s? (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • 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
    Friday, June 3, 2011 5:12 PM

Answers

  • minka replied on 08-07-2009 11:14 AM

    This is fixed in Infer.NET 2.3.

    Friday, June 3, 2011 5:12 PM

All replies

  • minka replied on 03-25-2009 1:29 PM

    Thanks for pointing this out.  It is indeed a bug and as a consequence it is not possible to use SharedVariableArrays in certain ways.  In your case, you are using the SharedVariableArray inside a Switch and this is causing the problem.  One workaround it is to perhaps reformulate your model using intermediate variables so that the SharedVariableArray does not appear inside the Switch.  We'll try to get a fix out as soon as possible.

    Friday, June 3, 2011 5:12 PM
  • minka replied on 08-07-2009 11:14 AM

    This is fixed in Infer.NET 2.3.

    Friday, June 3, 2011 5:12 PM