Github user mallman commented on a diff in the pull request:

    https://github.com/apache/spark/pull/165#discussion_r10714229
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/recommendation/ALS.scala ---
    @@ -187,21 +189,39 @@ class ALS private (
           }
         }
     
    -    for (iter <- 1 to iterations) {
    -      // perform ALS update
    -      logInfo("Re-computing I given U (Iteration %d/%d)".format(iter, 
iterations))
    -      // YtY / XtX is an Option[DoubleMatrix] and is only required for the 
implicit feedback model
    -      val YtY = computeYtY(users)
    -      val YtYb = ratings.context.broadcast(YtY)
    -      products = updateFeatures(users, userOutLinks, productInLinks, 
partitioner, rank, lambda,
    -        alpha, YtYb)
    -      logInfo("Re-computing U given I (Iteration %d/%d)".format(iter, 
iterations))
    -      val XtX = computeYtY(products)
    -      val XtXb = ratings.context.broadcast(XtX)
    -      users = updateFeatures(products, productOutLinks, userInLinks, 
partitioner, rank, lambda,
    -        alpha, XtXb)
    +    if (implicitPrefs) {
    +      for (iter <- 1 to iterations) {
    +        // perform ALS update
    +        logInfo("Re-computing I given U (Iteration %d/%d)".format(iter, 
iterations))
    +        // Persist users because it will be called twice.
    +        users.persist()
    +        val YtY = Some(sc.broadcast(computeYtY(users)))
    +        val previousProducts = products
    +        products = updateFeatures(users, userOutLinks, productInLinks, 
partitioner, rank, lambda,
    +          alpha, YtY)
    +        previousProducts.unpersist()
    +        logInfo("Re-computing U given I (Iteration %d/%d)".format(iter, 
iterations))
    +        products.persist()
    +        val XtX = Some(sc.broadcast(computeYtY(products)))
    +        val previousUsers = users
    +        users = updateFeatures(products, productOutLinks, userInLinks, 
partitioner, rank, lambda,
    +          alpha, XtX)
    +        previousUsers.unpersist()
    +      }
    +    } else {
    +      for (iter <- 1 to iterations) {
    +        // perform ALS update
    +        logInfo("Re-computing I given U (Iteration %d/%d)".format(iter, 
iterations))
    +        products = updateFeatures(users, userOutLinks, productInLinks, 
partitioner, rank, lambda,
    +          alpha, YtY = None)
    +        logInfo("Re-computing U given I (Iteration %d/%d)".format(iter, 
iterations))
    +        users = updateFeatures(products, productOutLinks, userInLinks, 
partitioner, rank, lambda,
    +          alpha, YtY = None)
    +      }
         }
     
    +    products.persist()
    --- End diff --
    
    Why is this here?


---
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.
---

Reply via email to