Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/7705#discussion_r35726235
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/clustering/LDAOptimizer.scala ---
@@ -385,59 +387,52 @@ final class OnlineLDAOptimizer extends LDAOptimizer {
iteration += 1
val k = this.k
val vocabSize = this.vocabSize
- val Elogbeta = dirichletExpectation(lambda).t
- val expElogbeta = exp(Elogbeta)
+ val expElogbeta = exp(LDAUtils.dirichletExpectation(lambda)).t
val alpha = this.alpha.toBreeze
val gammaShape = this.gammaShape
- val stats: RDD[BDM[Double]] = batch.mapPartitions { docs =>
+ val stats: RDD[(BDM[Double], List[BDV[Double]])] = batch.mapPartitions
{ docs =>
val stat = BDM.zeros[Double](k, vocabSize)
- docs.foreach { doc =>
- val termCounts = doc._2
- val (ids: List[Int], cts: Array[Double]) = termCounts match {
- case v: DenseVector => ((0 until v.size).toList, v.values)
- case v: SparseVector => (v.indices.toList, v.values)
- case v => throw new IllegalArgumentException("Online LDA does
not support vector type "
- + v.getClass)
+ var gammaPart = List[BDV[Double]]()
--- End diff --
Should this be allocated as a BDM from the start to avoid extra allocations?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]