You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spark.apache.org by rxin <gi...@git.apache.org> on 2014/03/01 03:16:09 UTC

[GitHub] spark pull request: Initialized the regVal for first iteration in ...

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

    https://github.com/apache/spark/pull/40#discussion_r10188555
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/optimization/GradientDescent.scala ---
    @@ -149,7 +149,14 @@ object GradientDescent extends Logging {
     
         // Initialize weights as a column vector
         var weights = new DoubleMatrix(initialWeights.length, 1, initialWeights:_*)
    -    var regVal = 0.0
    +
    +    /**
    +     * For the first iteration, the regVal will be initialized as sum of sqrt of
    +     * weights if it's L2 update; for L1 update; the same logic is followed.
    +     */
    +    var regVal = updater.compute(
    --- End diff --
    
    just a nit style pick here since @mengxr asked me to chime in.
    
    it would be better if you just put weights and the rest on the same line, e.g.
    
    ```scala
    var regVal = updater.compute(
      weights, new DoubleMatrix(initialWeights.length, 1), 0, 1, regParam)._2
    ```


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