srowen commented on a change in pull request #24963: [SPARK-28159][ML] Make the
transform natively in ml framework to avoid extra conversion
URL: https://github.com/apache/spark/pull/24963#discussion_r298630483
##########
File path:
mllib/src/main/scala/org/apache/spark/mllib/clustering/LDAOptimizer.scala
##########
@@ -642,6 +641,34 @@ private[clustering] object OnlineLDAOptimizer {
}
val sstatsd = expElogthetad.asDenseMatrix.t * (ctsVector /:/
phiNorm).asDenseMatrix
- (gammad, sstatsd, ids)
+ (gammad, sstatsd, indices)
+ }
+
+ private[clustering] def variationalTopicInference(
+ termCounts: Vector,
+ expElogbeta: BDM[Double],
+ alpha: breeze.linalg.Vector[Double],
+ gammaShape: Double,
+ k: Int,
+ seed: Long): (BDV[Double], BDM[Double], List[Int]) = {
+ 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)
+ }
+ variationalTopicInference(ids, cts, expElogbeta, alpha, gammaShape, k,
seed)
+ }
+
+ private[clustering] def variationalTopicInference(
+ termCounts: NewVector,
+ expElogbeta: BDM[Double],
+ alpha: breeze.linalg.Vector[Double],
+ gammaShape: Double,
+ k: Int,
+ seed: Long): (BDV[Double], BDM[Double], List[Int]) = {
+ val (ids: List[Int], cts: Array[Double]) = termCounts match {
+ case v: NewDenseVector => ((0 until v.size).toList, v.values)
Review comment:
I think we want to avoid materializing this list of indices. In the dense
case it's redundant. If not passed, assume the dense case?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]