leezu commented on issue #10768: Use numpy in RandomSampler
URL: https://github.com/apache/incubator-mxnet/pull/10768#issuecomment-386136121
 
 
   Thanks @asitstands . Comparing the numpy code to the mx.nd code you provided 
results in the following performance on my machine:
   ```
   
   In [3]: %timeit list(sample_mx(1529*8192))
   2.17 s ± 188 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
   
   In [4]: %timeit list(sample_np(1529*8192))
   1.3 s ± 73.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
   
   ```
   
   So relying on mx.nd.random.shuffle + asnumpy seems to add an extra second.
   
   Regarding RNG, our test cases set both numpy and mxnet seeds. I believe 
other parts of mxnet also use numpy random, so it may be good to document that 
both seeds must be set to get deterministic behavior. If this is the only place 
numpy.random is used it may be worth the extra second to stay consistent?

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