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

[MXNET-539] Allow Scala users to specify data/label names for NDArrayIter #11256

Merged
merged 3 commits into from
Jun 15, 2018

Conversation

yzhliu
Copy link
Member

@yzhliu yzhliu commented Jun 13, 2018

Description

So far Scala users cannot specify the names for NDArrayIter - they are inferred automatically (data_0, data_1, ..., etc)
We should allow users to do that since the input names are from model.

A builder class added so as to simplify object construction.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http:https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

@yzhliu yzhliu requested a review from nswamy June 13, 2018 06:51
if (!label.isEmpty) {
val labelList = label.map(ndArray => {ndArray.slice(0, keepSize)})
val labelList = label.map { case (name, ndArray) => (name, ndArray.slice(0, keepSize)) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will this slice handler be disposed?

require(cursor < numData, "DataIter needs reset.")
if (data == null) {
null
} else {
if (cursor + dataBatchSize <= numData) {
data.map(ndArray => {ndArray.slice(cursor, cursor + dataBatchSize)}).toIndexedSeq
data.map { case (_, ndArray) => ndArray.slice(cursor, cursor + dataBatchSize) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the user's(of this API) responsiblity to dispose the slice handler?, how would he know that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In next() it returns DataBatch and DataBatch can be disposed thus dispose the sliced data/label. For now it is a standard process for DataIters. Users can decide to use the returned DataBatch later thus we cannot dispose them here.

@nswamy nswamy merged commit 02e8a71 into apache:master Jun 15, 2018
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
…Iter (apache#11256)

* improve NDArrayIter to have Builder and ability to specifying names
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
…Iter (apache#11256)

* improve NDArrayIter to have Builder and ability to specifying names
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants