You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by WeichenXu123 <gi...@git.apache.org> on 2017/07/26 21:16:05 UTC

[GitHub] spark pull request #17373: [SPARK-12664] Expose probability in mlp model

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

    https://github.com/apache/spark/pull/17373#discussion_r129698281
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala ---
    @@ -527,9 +544,21 @@ private[ml] class FeedForwardModel private(
     
       override def predict(data: Vector): Vector = {
         val size = data.size
    -    val result = forward(new BDM[Double](size, 1, data.toArray))
    +    val result = forward(new BDM[Double](size, 1, data.toArray), true)
         Vectors.dense(result.last.toArray)
       }
    +
    +  override def predictRaw(data: Vector): Vector = {
    +    val size = data.size
    +    val result = forward(new BDM[Double](size, 1, data.toArray), false)
    +    Vectors.dense(result(result.length - 2).toArray)
    +  }
    +
    +  override def raw2ProbabilityInPlace(data: Vector): Vector = {
    +    val dataMatrix = new BDM[Double](data.size, 1, data.toArray)
    --- End diff --
    
    add `raw2ProbabilityInPlace`, what it compute is:
    ```
    softmax(rawPredictionsVector) ==> predictionsVector
    ```
    directly call the last layer function to compute it.


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