goete111 / factorie

Automatically exported from code.google.com/p/factorie
0 stars 0 forks source link

Assertion Failed Exception in Collapsed Gibbs Sampling #29

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Here's the code I'm trying to run (modeled after LDA2) in factorie 10.2

 val phis = Mixture(numTopics)(ProportionsVariable.growableDense(WordDomain.values) ~ Dirichlet(beta))

    while(cur.hasNext()) {
      var value = cur.next()
      var line = value.get(textField).toString
      if(line != null && line.size > 2){
        blackList.foreach(bl => line = line.replace(bl, ""))
       val theta = ProportionsVariable.dense(numTopics) ~ Dirichlet(alphas)
        val tokens = alphaSegmenter(line).map(_ toLowerCase).filter(!Stopwords.contains(_)).toSeq
        if(tokens !=null && tokens.length > 0){                     //might be empty because of stop words
         // tokens.foreach(t => println(t))
          val zs = new Zs(tokens.length) :~ PlatedDiscrete(theta)
          documents += new Document(line, theta, tokens) ~ PlatedDiscreteMixture(phis, zs)
        }
      }
    }

What is the expected output? What do you see instead?
Exception in thread "main" java.lang.AssertionError: assertion failed
    at scala.Predef$.assert(Predef.scala:146)
    at cc.factorie.Proportions$class.sampleIndex(ProportionsVariable.scala:34)
    at cc.factorie.DenseProportions1.sampleIndex(ProportionsVariable.scala:98)
    at cc.factorie.generative.PlatedDiscrete$$anonfun$sampledValue$1.apply(PlatedDiscrete.scala:33)
    at cc.factorie.generative.PlatedDiscrete$$anonfun$sampledValue$1.apply(PlatedDiscrete.scala:33)
    at scala.collection.generic.GenTraversableFactory.fill(GenTraversableFactory.scala:82)
    at cc.factorie.generative.PlatedDiscrete$.sampledValue(PlatedDiscrete.scala:33)
    at cc.factorie.generative.PlatedDiscrete$Factor.sampledValue(PlatedDiscrete.scala:37)
    at cc.factorie.MutableVar$class.$colon$tilde(Variable.scala:132)
    at cc.factorie.DiscreteSeqVariable.$colon$tilde(DiscreteSeqVariable.scala:33)
    at projectx.auto.LoadNHTSAData$.main(LoadNHTSAData.scala:87)
    at projectx.auto.LoadNHTSAData.main(LoadNHTSAData.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

What version of the product are you using? On what operating system?
I'm using factorie 0.10.2 on windows. 

Please provide any additional information below.

I had an older version of this topic model code, which did not use 
ProportionsVariable and it worked fine. Please help. 

Original issue reported on code.google.com by pall...@gmail.com on 10 Sep 2012 at 10:00

GoogleCodeExporter commented 8 years ago
I meant the Proportions class. (I had Collapsed Gibbs Sampler in my mind when I 
wrote about this bug)

Original comment by pall...@gmail.com on 10 Sep 2012 at 10:04