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

[R] mx.io.arrayiter shuffing is disabled #9804

Closed
jeremiedb opened this issue Feb 16, 2018 · 4 comments
Closed

[R] mx.io.arrayiter shuffing is disabled #9804

jeremiedb opened this issue Feb 16, 2018 · 4 comments
Assignees
Labels

Comments

@jeremiedb
Copy link
Contributor

mx.io.arrayiter shuffling option is no longer working, the option only result in the first and last samples to be swapped. Likely appeared at the same time that mx.runif stopped working as well.

> mx.set.seed(44)
> x = mx.io.arrayiter(data = 1:10, label = 1:10, shuffle = T, batch.size = 10)
> x$reset()
> x$iter.next()
[1] TRUE
> x$value()
$data
 [1]  2  3  4  5  6  7  8  9 10  1

$label
 [1]  2  3  4  5  6  7  8  9 10  1

> 
> mx.set.seed(21)
> y = mx.io.arrayiter(data = 1:10, label = 1:10, shuffle = T, batch.size = 10)
> y$reset()
> y$iter.next()
[1] TRUE
> y$value()
$data
 [1]  2  3  4  5  6  7  9  8 10  1

$label
 [1]  2  3  4  5  6  7  9  8 10  1
@Roshrini
Copy link
Member

@thirdwing Can you please take a look?

@anirudhacharya
Copy link
Member

anirudhacharya commented Apr 3, 2018

@hetong007 any update on this.
Also there does not seem to be a test for "shuffle=TRUE" case - /~https://github.com/apache/incubator-mxnet/blob/master/R-package/tests/testthat/test_io.R#L63-L85
@thirdwing

@anirudhacharya
Copy link
Member

This issue is not reproducible on Mac with my RStudio installation. But I am able to reproduce it on one of my EC2 instances.

The only difference in the two installations is the mxnet version -
In Mac I am running

other attached packages:
[1] mxnet_0.10.1

whereas on the ubuntu installation I am running the latest version -

other attached packages:
[1] mxnet_1.2.0

The root cause of the problem is the behavior of mxnet's uniform distribution generator which is internally used for shuffling the arrayiter object.
On the old code, I get the following

> mx.runif(shape=10, min=0, max=1, ctx=mx.cpu())
 [1] 0.04804938 0.65167809 0.77450776 0.67896259 0.21799077 0.29066718 0.08128081 0.97726691 0.04218456 0.40008616

On the latest mxnet v1.2 I get the following -

> mx.runif(shape=10, min=0, max=1, ctx=mx.cpu())
 [1] 1.168184e-35 0.000000e+00 0.000000e+00 2.522337e-44 0.000000e+00
 [6] 0.000000e+00 1.401298e-45 0.000000e+00 6.726233e-44 0.000000e+00

Similar errors exist for the mx.rnorm too in the latest code.

@anirudhacharya
Copy link
Member

@sandeep-krishnamurthy please close this issue. It has been fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants