spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mengxr <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-5016][MLLib] Distribute GMM mixture com...
Date Wed, 08 Jul 2015 18:00:44 GMT
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7166#discussion_r34178310
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/GaussianMixture.scala
---
    @@ -171,14 +177,25 @@ class GaussianMixture private (
           // Create new distributions based on the partial assignments
           // (often referred to as the "M" step in literature)
           val sumWeights = sums.weights.sum
    -      var i = 0
    -      while (i < k) {
    -        val mu = sums.means(i) / sums.weights(i)
    -        BLAS.syr(-sums.weights(i), Vectors.fromBreeze(mu),
    -          Matrices.fromBreeze(sums.sigmas(i)).asInstanceOf[DenseMatrix])
    -        weights(i) = sums.weights(i) / sumWeights
    -        gaussians(i) = new MultivariateGaussian(mu, sums.sigmas(i) / sums.weights(i))
    -        i = i + 1
    +
    +      if (distributeGaussians) {
    +        val (ws, gs) = sc.parallelize(0 until k, math.min(k, 1024)).map { i =>
    +          updateWeightsAndGaussians(sums.means(i), sums.sigmas(i), sums.weights(i), sumWeights)
    --- End diff --
    
    This might result broadcasting sums to all partitions. Could you try
    
    ~~~scala
    val tuples = Seq.tabulate(i => (sums.means(i), sums.sigmas(i), sums.weights(i)))
    sc.parallelize(tuples, math.min(k, 1024)).map { case (mean, sigma, weight) =>
      updateWeightsAndGaussians(mean, sigma, weight, sumWeighs)
    }
    ~~~


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message