spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkbradley <...@git.apache.org>
Subject [GitHub] spark pull request #17373: [SPARK-12664][ML] Expose probability in mlp model
Date Mon, 14 Aug 2017 22:58:38 GMT
Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17373#discussion_r133081809
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala ---
    @@ -527,9 +550,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)
    +    layerModels.last.eval(dataMatrix, dataMatrix)
    --- End diff --
    
    This assumes that the ```eval``` method can operate in-place.  That is fine for the last
layer for MLP (SoftmaxLayerModelWithCrossEntropyLoss), but not OK in general.  More generally,
these methods for classifiers should not go in the very general TopologyModel abstraction;
that abstraction may be used in the future for regression as well.  I'd be fine with putting
this classification-specific logic in MLP itself; we do not need to generalize the logic until
we add other Classifiers, which might take a long time.


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