Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Scala: DataDesc IllegalArgumentException with simple example #12409

Closed

Description

@mariussoutier

Description

Fitting using Scala and Module API throws an IAE.
Apparently the label shape of (50) doesn't correspond to expected the NCHW format.

Environment info (Required)

macOS 10.13.6
IntelliJ 2018.2.2
Scala 2.11.12
Java 1.8.0_121
MXNet 1.2.1

Error Message:

Exception in thread "main" java.lang.IllegalArgumentException: requirement failed: number of dimensions in shape :1 with shape: (50) should match the length of the layout: 4 with layout: NCHW
	at scala.Predef$.require(Predef.scala:224)
	at org.apache.mxnet.DataDesc.<init>(IO.scala:233)
	at org.apache.mxnet.DataDesc$$anonfun$ListMap2Descs$1.apply(IO.scala:256)
	at org.apache.mxnet.DataDesc$$anonfun$ListMap2Descs$1.apply(IO.scala:256)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.Iterator$class.foreach(Iterator.scala:891)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
	at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
	at scala.collection.AbstractTraversable.map(Traversable.scala:104)
	at org.apache.mxnet.DataDesc$.ListMap2Descs(IO.scala:256)
	at org.apache.mxnet.module.BaseModule.fit(BaseModule.scala:399)

Minimum reproducible example

    val trainDataIter = IO.ImageRecordIter(Map(
      "data_name" -> dataName,
      "path_imgrec" -> this.getClass.getResource("/data/mydata.rec").getFile,
      "data_shape" -> "(3,128,128)",
      "batch_size" -> "50"
    ))

val mod = new Module(mlp)
    mod.fit(
      trainDataIter,
      Some(testDataIter),
      numEpoch = 10,
      fitParams =
        new FitParams()
          .setOptimizer(new SGD(0.1f, 0.9f, 0.0001f))
    )

Tried debugging this, but pretty difficult to find out what's going on with a stringly typed API.

println(trainDataIter.provideData) -> Map(data -> (50,3,128,128))
println(trainDataIter.provideLabel) -> Map(label -> (50))

Activity

  1. anirudhacharya commented on Aug 30, 2018

    @anirudhacharya
    Member
  2. lanking520 commented on Aug 30, 2018

    @lanking520
    Member

    Hi @mariussoutier this problem actually addressed in 1.3 in this PR: #11844. Try with this one!

  3. mariussoutier commented on Aug 31, 2018

    @mariussoutier
    Author

    @lanking520 Is there a published version of that I can use or do I have to build it myself?

  4. lanking520 commented on Sep 1, 2018

    @lanking520
    Member

    Unfortunately, you need to build from source with 1.3 or please wait for us to publish that. It will be out very soon.

  5. mariussoutier commented on Sep 2, 2018

    @mariussoutier
    Author

    Ok I'll test again then. I feel like the Scala API could use some love :-)

  6. nswamy commented on Sep 4, 2018

    @nswamy
    Member

    @mariussoutier we are working on a 1.3.0 pre-release, we should be able to have a RC maven package in staging soon.

  7. mariussoutier commented on Sep 8, 2018

    @mariussoutier
    Author

    Nice, looking forward to it.

  8. nswamy commented on Sep 12, 2018

    @nswamy
    Member
  9. mariussoutier commented on Sep 13, 2018

    @mariussoutier
    Author

    @nswamy Just tried it out, Module API seems to work now. Thanks!

  10. mariussoutier commented on Sep 13, 2018

    @mariussoutier
    Author

    Is there any difference between Module and FeedForward anyway?

  11. nswamy commented on Sep 13, 2018

    @nswamy
    Member

    Feedforward as the name suggests works for FeedForward networks which are single input/single output but Module APIs will work for multi-input/multi-output FeedForward and CNNs, GANs, RNNs(probably requires the extended Bucketing Module which is in examples)

  12. mariussoutier commented on Sep 13, 2018

    @mariussoutier
    Author

    Ok, makes sense. I've also used FeedForward for my CNN :-)

  13. mariussoutier commented on Sep 13, 2018

    @mariussoutier
    Author

    One more issue, Module-based GPU training on Ubuntu fails during the second epoch with a SIGTERM. I don't know yet what's happening. FeedForward-based training in 1.2.1 works without a problem.

  14. nswamy commented on Sep 13, 2018

    @nswamy
    Member

    could you please open a new issue with some reproducible code?

  15. mariussoutier commented on Sep 13, 2018

    @mariussoutier
    Author

    Sure, will do.

  16. ddavydenko commented on Sep 25, 2018

    @ddavydenko
    Contributor

    Seems like this extra question was filed and replied to in #12553. Could we close this issue as it has been addressed in comments above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions