[GitHub] spark pull request #15060: [SPARK-17507][ML][MLLib] check weight vector size...
Github user asfgit closed the pull request at: https://github.com/apache/spark/pull/15060 --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #15060: [SPARK-17507][ML][MLLib] check weight vector size...
Github user WeichenXu123 commented on a diff in the pull request: https://github.com/apache/spark/pull/15060#discussion_r78749771 --- Diff: mllib/src/main/scala/org/apache/spark/ml/classification/MultilayerPerceptronClassifier.scala --- @@ -235,6 +235,7 @@ class MultilayerPerceptronClassifier @Since("1.5.0") ( */ override protected def train(dataset: Dataset[_]): MultilayerPerceptronClassificationModel = { val myLayers = $(layers) +require(myLayers != null, "layers parameter not set.") --- End diff -- OK I will remove the check. thanks! --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #15060: [SPARK-17507][ML][MLLib] check weight vector size...
Github user MLnick commented on a diff in the pull request: https://github.com/apache/spark/pull/15060#discussion_r78697474 --- Diff: mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala --- @@ -545,7 +545,8 @@ private[ann] object FeedForwardModel { * @return model */ def apply(topology: FeedForwardTopology, weights: Vector): FeedForwardModel = { -// TODO: check that weights size is equal to sum of layers sizes +require(weights.size == topology.layers.map(_.weightSize).sum, + "Input weight vector has illegal size.") --- End diff -- Prefer a more informative error message here, like "Expected weight vector of size $x but got size $y" --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #15060: [SPARK-17507][ML][MLLib] check weight vector size...
Github user MLnick commented on a diff in the pull request: https://github.com/apache/spark/pull/15060#discussion_r78697410 --- Diff: mllib/src/main/scala/org/apache/spark/ml/classification/MultilayerPerceptronClassifier.scala --- @@ -235,6 +235,7 @@ class MultilayerPerceptronClassifier @Since("1.5.0") ( */ override protected def train(dataset: Dataset[_]): MultilayerPerceptronClassificationModel = { val myLayers = $(layers) +require(myLayers != null, "layers parameter not set.") --- End diff -- is this really required? because `$layers` should call `getOrDefault` and if there is no default and it is not set, it already throws an erorr --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #15060: [SPARK-17507][ML][MLLib] check weight vector size...
Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/15060#discussion_r78409055 --- Diff: mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala --- @@ -545,7 +553,9 @@ private[ann] object FeedForwardModel { * @return model */ def apply(topology: FeedForwardTopology, weights: Vector): FeedForwardModel = { -// TODO: check that weights size is equal to sum of layers sizes +if (weights.size != topology.weightSize) { + throw new Exception("Input weight vector has illegal size.") --- End diff -- Throwing Exception is never great ... use `require` for consistency. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #15060: [SPARK-17507][ML][MLLib] check weight vector size...
Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/15060#discussion_r78408999 --- Diff: mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala --- @@ -395,6 +395,14 @@ private[ann] class FeedForwardTopology private(val layers: Array[Layer]) extends override def model(weights: Vector): TopologyModel = FeedForwardModel(this, weights) override def model(seed: Long): TopologyModel = FeedForwardModel(this, seed) + + def weightSize: Int = { --- End diff -- Just `layers.map(_.weightSize).sum`? You don't even need a method really. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #15060: [SPARK-17507][ML][MLLib] check weight vector size...
GitHub user WeichenXu123 opened a pull request: https://github.com/apache/spark/pull/15060 [SPARK-17507][ML][MLLib] check weight vector size in ANN ## What changes were proposed in this pull request? as the TODO described, check weight vector size and if wrong throw exception. ## How was this patch tested? existing tests. You can merge this pull request into a Git repository by running: $ git pull https://github.com/WeichenXu123/spark check_input_weight_size_of_ann Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/15060.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #15060 commit e89aef5fbd5be5b255e623cdfca8ae75ecb92ea3 Author: WeichenXu Date: 2016-09-12T10:15:25Z update. --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org