srowen commented on a change in pull request #26838: [SPARK-30144][ML][PySpark] 
Make MultilayerPerceptronClassificationModel extend MultilayerPerceptronParams
URL: https://github.com/apache/spark/pull/26838#discussion_r357833843
 
 

 ##########
 File path: 
mllib/src/main/scala/org/apache/spark/ml/classification/MultilayerPerceptronClassifier.scala
 ##########
 @@ -369,11 +377,18 @@ object MultilayerPerceptronClassificationModel
       val metadata = DefaultParamsReader.loadMetadata(path, sc, className)
 
       val dataPath = new Path(path, "data").toString
-      val data = sparkSession.read.parquet(dataPath).select("layers", 
"weights").head()
-      val layers = data.getAs[Seq[Int]](0).toArray
-      val weights = data.getAs[Vector](1)
-      val model = new MultilayerPerceptronClassificationModel(metadata.uid, 
layers, weights)
-
+      val columns = sparkSession.read.parquet(dataPath).columns
+      val model = if (columns.length == 2) { // model prior to 3.0.0
+        val data = sparkSession.read.parquet(dataPath).select("layers", 
"weights").head()
+        val layers = data.getAs[Seq[Int]](0).toArray
+        val weights = data.getAs[Vector](1)
+        val model = new MultilayerPerceptronClassificationModel(metadata.uid, 
weights)
+         model.setLayers(layers)
+      } else {
+        val data = sparkSession.read.parquet(dataPath).select("weights").head()
+        val weights = data.getAs[Vector](0)
+        new MultilayerPerceptronClassificationModel(metadata.uid, weights)
 
 Review comment:
   Pardon the dumb question, but, why does the new model version not need to 
load layers? is it part of weights?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to