parallelgithub commented on a change in pull request #9771: Modify NDArrayIter 
constructor to receive tuple (i.e. dict in Python)?
URL: https://github.com/apache/incubator-mxnet/pull/9771#discussion_r168052820
 
 

 ##########
 File path: scala-package/core/src/main/scala/ml/dmlc/mxnet/io/NDArrayIter.scala
 ##########
 @@ -38,15 +38,14 @@ import scala.collection.immutable.ListMap
  * the size of data does not match batch_size. Roll over is intended
  * for training and can cause problems if used for prediction.
  */
-class NDArrayIter (data: IndexedSeq[NDArray], label: IndexedSeq[NDArray] = 
IndexedSeq.empty,
-                  private val dataBatchSize: Int = 1, shuffle: Boolean = false,
-                  lastBatchHandle: String = "pad",
-                  dataName: String = "data", labelName: String = "label") 
extends DataIter {
+class NDArrayIter (data: IndexedSeq[(String, NDArray)], label: 
IndexedSeq[(String, NDArray)],
+                  private val dataBatchSize: Int, shuffle: Boolean,
+                  lastBatchHandle: String) extends DataIter {
 
 Review comment:
   @cjolivier01
   
   Thank you for giving a direction to think about it.
   
   Let me explain why it is difficult to design it in that way.
   Here is an example of overloading constructor in Scala:
   
   ```scala
   class A(i: Int) {
     \\ Part 1
     val initData = 5
     def this(i: Int, j: Int) = {
       \\ You can't write anything here
       this(i + j)
       \\ Part 3
     }
     \\ Part 2
     def getData() = initData
   }
   ```
   If `new A(10)`, Part 1 and Part 2 will be executed.
   If `new A(10, 20)`, Part 1, Part 2, and the Part 3 will be executed.
   When you initialize fields and methods in Part 1 and Part 2, it's late to do 
anything in Part 3.
   When executing 'common' portion Part 1 and Part 2, we must pass the original 
version of argument set, which loses the information of custom names for 
multiple input.
   
   One possible way is declaring the field as `var`.
   Since using mutable variable is not good for maintaining program, I don't 
recommend this way.
   
   Maybe there is an [alternative 
strategy](https://github.com/Ldpe2G/DeepLearningForFun/blob/master/Mxnet-Scala/MatrixFactorization/matrixFac.scala)
 to manipulate multiple input. 
   It doesn't use `Module` so that avoid using `NDArrayIter`. 
   Since `Module` aims to provide high-level API, I think it's worthy to 
dedicated to `NDArrayIter`.

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