nswamy commented on a change in pull request #11605: Updating MultiTask example 
to use new infer api and adding test for CI
URL: https://github.com/apache/incubator-mxnet/pull/11605#discussion_r201789116
 
 

 ##########
 File path: 
scala-package/examples/src/test/scala/org/apache/mxnetexamples/multitask/MultiTaskTest.scala
 ##########
 @@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mxnetexamples.multitask
+
+import org.apache.commons.io.FileUtils
+import org.apache.mxnet.Context
+import org.scalatest.{BeforeAndAfterAll, FunSuite}
+import org.slf4j.LoggerFactory
+import org.apache.mxnet.Symbol
+import org.apache.mxnet.DataIter
+import org.apache.mxnet.DataBatch
+import org.apache.mxnet.NDArray
+import org.apache.mxnet.Shape
+import org.apache.mxnet.EvalMetric
+import org.apache.mxnet.Context
+import org.apache.mxnet.Xavier
+import org.apache.mxnet.optimizer.RMSProp
+
+import java.io.File
+import java.net.URL
+
+import scala.sys.process.Process
+import scala.collection.immutable.ListMap
+import scala.collection.immutable.IndexedSeq
+
+import scala.collection.mutable.{ArrayBuffer, ListBuffer}
+
+
+/**
+  * Integration test for imageClassifier example.
+  * This will run as a part of "make scalatest"
+  */
+class MultiTaskTest extends FunSuite with BeforeAndAfterAll {
+
+  def getListOfFiles(dir: File): List[File] = 
dir.listFiles.filter(_.isFile).toList
+
+  private val logger = LoggerFactory.getLogger(classOf[MultiTaskTest])
+
+  logger.info("Multitask Test...")
+
+  val baseUrl = 
"https://s3.us-east-2.amazonaws.com/mxnet-scala/scala-example-ci";
+  val tempDirPath = System.getProperty("java.io.tmpdir")
+  val modelDirPath = tempDirPath + File.separator + "multitask/"
+  val tmpFile = new File(tempDirPath + "/multitask/mnist.zip")
+  if (!tmpFile.exists()) {
+    FileUtils.copyURLToFile(new URL(baseUrl + "/mnist/mnist.zip"),
+      tmpFile)
+  }
+
+  // TODO: Need to confirm with Windows
+
+
+  Process("unzip " + tempDirPath + "/multitask/mnist.zip -d "
+    + tempDirPath + "/multitask/") !
+
+  val batchSize = 100
+  val numEpoch = 10
+  val ctx = Context.cpu()
+  val lr = 0.001f
+  val network = ExampleMultiTask.buildNetwork()
+  val (trainIter, valIter) =
+    Data.mnistIterator(modelDirPath, batchSize = batchSize, inputShape = 
Shape(784))
+  val trainMultiIter = new ExampleMultiTask.MultiMnistIterator(trainIter)
+  val valMultiIter = new ExampleMultiTask.MultiMnistIterator(valIter)
+
+  val datasAndLabels = trainMultiIter.provideData ++ 
trainMultiIter.provideLabel
+
+  val (argShapes, outputShapes, auxShapes) = 
network.inferShape(trainMultiIter.provideData("data"))
 
 Review comment:
   bulk of the code in this file is training code, can you move it to generic 
runTraining method inside of the example, so customers can directly use it?  
you can call the runTraining code by passing training/test files, etc.,

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


With regards,
Apache Git Services

Reply via email to