[GitHub] wkcn opened a new issue #9216: Loss of Precision in BatchNorm and output_var may be wrong

2017-12-27 Thread GitBox
wkcn opened a new issue #9216: Loss of Precision in BatchNorm and output_var 
may be wrong
URL: https://github.com/apache/incubator-mxnet/issues/9216
 
 
   ## Description
   1. BatchNorm loses a little precision
   2. the output_var in BatchNorm may be wrong
   
   ## Environment Info
   OS: Arch Linux 4.14.8
   MXNet: 1.0.0 and 1.0.1 (the latest version, CPU version)
   
   ## Build Config
   make -j8 USE_OPENCV=1 USE_BLAS=openblas
   ***
   
   Hi, there.
   
   I converted [ResNet Model on 
Caffe](https://github.com/KaimingHe/deep-residual-networks) to [ResNet model on 
MXNet](https://github.com/wkcn/resnet-v1-mx).
   
   And I found that the output results between Caffe and MXNet are different.
   
   The reason is that the computations of Caffe and MXNet are different.
   
   For the BatchNorm in Caffe, the output is `(x - mean(x)) / sqrt(var(x) + 
eps)`.
   
   For the BatchNorm in MXNet, the output is `(x - mean(x)) * factor`, and 
`factor = 1.0 / sqrt(var(x) + eps)`.
   
   I think the method in MXNet will **lose a little precision** but bring the 
**higher performance** (Reduce the times of division).
   
   At the same time, I found that the `output_var` in BatchNorm may be wrong. 
   
   The `output_var` is **invstd**, namely the multiplicative inverse of the 
standard deviation. I think it should be the variance.
   
   ## Steps to reproduce
   
   Here is [my testing code](https://github.com/wkcn/test_mxnet_bn).
   
   I compare three outputs:
   
   - numpy (compute manally)
   - caffe
   - mxnet
   
   ```
   caffe and numpy 0.0 0.0
   caffe and mx 16.0 2.36527e-07
   numpy and mx 16.0 2.36527e-07
   ```
   
   The first column is the `maxmimum absolute error`, and the second column is 
the `maxmimum relative error`.
   
   # What I have tried to solve it
   
   I change the BatchNorm implement in MXNet, and the output is below:
   
   ```
   caffe and numpy 0.0 0.0
   caffe and mx 0.0 0.0
   numpy and mx 0.0 0.0
   ```
   
   The modified BatchNorm(cpu) code is 
[here](https://github.com/wkcn/incubator-mxnet/commit/5ecd4882bc043cf059e962f7ce488270bafa07c7).
   


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


[GitHub] sxjscience commented on issue #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
sxjscience commented on issue #9200: Fix the gradient of gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#issuecomment-354243102
 
 
   It's very strange. The CI test fails on all windows machines.


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


[GitHub] sxjscience commented on issue #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
sxjscience commented on issue #9200: Fix the gradient of gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#issuecomment-354243102
 
 
   It's very strange. The test fails on all windows machines.


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


[GitHub] fedorzh commented on issue #9185: Gluon provided ResNet does not get desirable accuracy on CIFAR10

2017-12-27 Thread GitBox
fedorzh commented on issue #9185: Gluon provided ResNet does not get desirable 
accuracy on CIFAR10
URL: 
https://github.com/apache/incubator-mxnet/issues/9185#issuecomment-354227268
 
 
   That's cool, but I was talking about the non bottleneck versions. The 
repository I pointed to used non-bonon-bottleneck for CIFAR


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


[GitHub] szha commented on issue #9185: Gluon provided ResNet does not get desirable accuracy on CIFAR10

2017-12-27 Thread GitBox
szha commented on issue #9185: Gluon provided ResNet does not get desirable 
accuracy on CIFAR10
URL: 
https://github.com/apache/incubator-mxnet/issues/9185#issuecomment-354226502
 
 
   @leoxiaobin We discovered that there's inconsistency between resnetv1 
bottleneck versions in model zoo and the original paper. The imagenet accuracy 
for resnet50/101_v1 should be improved after #9215, as you can see the numbers 
there.


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


[GitHub] szha commented on issue #8859: Is there a pretrained mobilenet weights in model zoo?

2017-12-27 Thread GitBox
szha commented on issue #8859: Is there a pretrained mobilenet weights in model 
zoo?
URL: 
https://github.com/apache/incubator-mxnet/issues/8859#issuecomment-354225965
 
 
   This will be resolved in #9215 


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


[GitHub] szha commented on issue #8977: v1.0 with NCCL

2017-12-27 Thread GitBox
szha commented on issue #8977: v1.0 with NCCL
URL: 
https://github.com/apache/incubator-mxnet/issues/8977#issuecomment-354223384
 
 
   pip version 1.0.0.post2 for cu80/cu80mkl/cu90/cu90mkl now supports nccl out 
of the box.
   
   We will consider turning on USE_PROFILER once its performance impact is 
evaluated and considered tolerable.


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


[GitHub] szha closed issue #8977: v1.0 with NCCL

2017-12-27 Thread GitBox
szha closed issue #8977: v1.0 with NCCL
URL: https://github.com/apache/incubator-mxnet/issues/8977
 
 
   


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


[GitHub] ptrendx commented on issue #8414: Fix the strides in Gluon version of ResNet v1

2017-12-27 Thread GitBox
ptrendx commented on issue #8414: Fix the strides in Gluon version of ResNet v1
URL: https://github.com/apache/incubator-mxnet/pull/8414#issuecomment-354221869
 
 
   Closing due to #9215 


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


[GitHub] ptrendx closed pull request #8414: Fix the strides in Gluon version of ResNet v1

2017-12-27 Thread GitBox
ptrendx closed pull request #8414: Fix the strides in Gluon version of ResNet v1
URL: https://github.com/apache/incubator-mxnet/pull/8414
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/mxnet/gluon/model_zoo/vision/resnet.py 
b/python/mxnet/gluon/model_zoo/vision/resnet.py
index c45b854bcb..9d1d9d303a 100644
--- a/python/mxnet/gluon/model_zoo/vision/resnet.py
+++ b/python/mxnet/gluon/model_zoo/vision/resnet.py
@@ -102,10 +102,10 @@ class BottleneckV1(HybridBlock):
 def __init__(self, channels, stride, downsample=False, in_channels=0, 
**kwargs):
 super(BottleneckV1, self).__init__(**kwargs)
 self.body = nn.HybridSequential(prefix='')
-self.body.add(nn.Conv2D(channels//4, kernel_size=1, strides=1))
+self.body.add(nn.Conv2D(channels//4, kernel_size=1, strides=stride))
 self.body.add(nn.BatchNorm())
 self.body.add(nn.Activation('relu'))
-self.body.add(_conv3x3(channels//4, stride, channels//4))
+self.body.add(_conv3x3(channels//4, 1, channels//4))
 self.body.add(nn.BatchNorm())
 self.body.add(nn.Activation('relu'))
 self.body.add(nn.Conv2D(channels, kernel_size=1, strides=1))


 


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


[GitHub] zhreshold opened a new pull request #9215: [WIP] Adding multiple pretrained models

2017-12-27 Thread GitBox
zhreshold opened a new pull request #9215: [WIP] Adding multiple pretrained 
models
URL: https://github.com/apache/incubator-mxnet/pull/9215
 
 
   | Model | Top 1 | Top 5 |
   |:-:|:--:|:--:|
   | mobilenet0.25 | 0.5185 | 0.7608 |
   | mobilenet0.5 | 0.6307 | 0.8475 |
   | mobilenet0.75 | 0.6738 | 0.8782 |
   | mobilenet1.0 | 0.7105 | 0.9006 |
   | resnet50_v1 | 0.7540 | 0.9266 |
   | resnet101_v1 | 0.7693 | 0.9334 |
   | resnet152_v1 | training | training |
   | resnet50_v2 | 0.7622 | 0.9297 |
   | resnet101_v2 | 0.7747 | 0.9375 |
   | resnet152_v2 | 0.7833 | 0.9409 |
   
   Minor fixes:
   - Fix resnetv1 strides, overrides #8414 if @ptrendx don't mind.
   - Fixes batchnorm scale issue in mobilenet.


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


[GitHub] szha commented on issue #8903: pull the libgfortran dependency in the mxnet pip package

2017-12-27 Thread GitBox
szha commented on issue #8903: pull the libgfortran dependency in the mxnet pip 
package
URL: 
https://github.com/apache/incubator-mxnet/issues/8903#issuecomment-354221267
 
 
   The problem should have been resolved in mxnet==1.0.0.post2, pending 
validation. This issue has the same resolution as 9048 so let's track the 
progress there.


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


[GitHub] szha closed issue #8903: pull the libgfortran dependency in the mxnet pip package

2017-12-27 Thread GitBox
szha closed issue #8903: pull the libgfortran dependency in the mxnet pip 
package
URL: https://github.com/apache/incubator-mxnet/issues/8903
 
 
   


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


[GitHub] szha commented on issue #9048: pip package relies on outdated libgfortran.so version

2017-12-27 Thread GitBox
szha commented on issue #9048: pip package relies on outdated libgfortran.so 
version
URL: 
https://github.com/apache/incubator-mxnet/issues/9048#issuecomment-354221084
 
 
   The problem should have been resolved in mxnet==1.0.0.post2. @leezu could 
you check and see if the post2 version fixes the problem for you?


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


[GitHub] szha closed pull request #9212: Modified nce-loss README to use image files in dmlc/web-data repo

2017-12-27 Thread GitBox
szha closed pull request #9212: Modified nce-loss README to use image files in 
dmlc/web-data repo
URL: https://github.com/apache/incubator-mxnet/pull/9212
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/example/nce-loss/README.md b/example/nce-loss/README.md
index edcb04a9ee..70730b4772 100644
--- a/example/nce-loss/README.md
+++ b/example/nce-loss/README.md
@@ -63,9 +63,9 @@ The motivation is to design a more robust and scalable word 
vector system, by re
 
 ### Basics
 
-https://github.com/zihaolucky/mxnet/blob/example/word2vec-nce-loss-with-subword-representations/example/nce-loss-subword-repr/slide1.png;
 width="700">
+https://github.com/dmlc/web-data/blob/master/mxnet/example/nce-loss/images/slide1.png;
 width="700">
 
-https://github.com/zihaolucky/mxnet/blob/example/word2vec-nce-loss-with-subword-representations/example/nce-loss-subword-repr/slide2.png;
 width="700">
+https://github.com/dmlc/web-data/blob/master/mxnet/example/nce-loss/images/slide2.png;
 width="700">
 
 Note that this word embedding method uses sub-word units to represent a word, 
while we still train word2vec model in its original way, the only difference is 
the vector representation of a word is no longer the word itself, but use 
several sub-word units' addition.
 


 


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


[incubator-mxnet] branch master updated: Modified nce-loss README to use image files in dmlc/web-data repo (#9212)

2017-12-27 Thread zhasheng
This is an automated email from the ASF dual-hosted git repository.

zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new 2586c66  Modified nce-loss README to use image files in dmlc/web-data 
repo (#9212)
2586c66 is described below

commit 2586c6691ca74d2df455a49cad964bcac8e34f25
Author: Sina Afrooze 
AuthorDate: Wed Dec 27 19:10:48 2017 -0800

Modified nce-loss README to use image files in dmlc/web-data repo (#9212)
---
 example/nce-loss/README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/example/nce-loss/README.md b/example/nce-loss/README.md
index edcb04a..70730b4 100644
--- a/example/nce-loss/README.md
+++ b/example/nce-loss/README.md
@@ -63,9 +63,9 @@ The motivation is to design a more robust and scalable word 
vector system, by re
 
 ### Basics
 
-https://github.com/zihaolucky/mxnet/blob/example/word2vec-nce-loss-with-subword-representations/example/nce-loss-subword-repr/slide1.png;
 width="700">
+https://github.com/dmlc/web-data/blob/master/mxnet/example/nce-loss/images/slide1.png;
 width="700">
 
-https://github.com/zihaolucky/mxnet/blob/example/word2vec-nce-loss-with-subword-representations/example/nce-loss-subword-repr/slide2.png;
 width="700">
+https://github.com/dmlc/web-data/blob/master/mxnet/example/nce-loss/images/slide2.png;
 width="700">
 
 Note that this word embedding method uses sub-word units to represent a word, 
while we still train word2vec model in its original way, the only difference is 
the vector representation of a word is no longer the word itself, but use 
several sub-word units' addition.
 

-- 
To stop receiving notification emails like this one, please contact
['"comm...@mxnet.apache.org" '].


[GitHub] javelinjs commented on issue #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
javelinjs commented on issue #9119: fix random generator: do not gen seed each 
time
URL: https://github.com/apache/incubator-mxnet/pull/9119#issuecomment-354216517
 
 
   merged changes from https://github.com/apache/incubator-mxnet/pull/9129


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


[GitHub] safrooze commented on issue #9214: CTC example trains very slowly (~250 samples/sec)

2017-12-27 Thread GitBox
safrooze commented on issue #9214: CTC example trains very slowly (~250 
samples/sec)
URL: 
https://github.com/apache/incubator-mxnet/issues/9214#issuecomment-354212132
 
 
   @yajiedesign any thoughts on this?


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


[GitHub] safrooze opened a new issue #9214: CTC example trains very slowly (~250 samples/sec)

2017-12-27 Thread GitBox
safrooze opened a new issue #9214: CTC example trains very slowly (~250 
samples/sec)
URL: https://github.com/apache/incubator-mxnet/issues/9214
 
 
   ## Description
   Running the lstm_ocr.py script in example/ctc doesn't train anywhere new the 
speed shown in the README logs. I get around 250 samples per second, while the 
example shows ~4200 samples per second. 
   
   ## Environment info (Required)
   ```
   --Python Info--
   Version  : 3.6.3
   Compiler : GCC 7.2.0
   Build: ('default', 'Nov 20 2017 20:41:42')
   Arch : ('64bit', '')
   Pip Info---
   Version  : 9.0.1
   Directory: 
/home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/pip
   --MXNet Info---
   Version  : 1.0.0
   Directory: 
/home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet
   Commit Hash   : 2b67436802b750e15b9fbfdf275958c1000be6a8
   --System Info--
   Platform : Linux-4.4.0-1044-aws-x86_64-with-debian-stretch-sid
   system   : Linux
   node : ip-172-31-32-80
   release  : 4.4.0-1044-aws
   version  : #53-Ubuntu SMP Mon Dec 11 13:49:57 UTC 2017
   --Hardware Info--
   machine  : x86_64
   processor: x86_64
   Architecture:  x86_64
   CPU op-mode(s):32-bit, 64-bit
   Byte Order:Little Endian
   CPU(s):32
   On-line CPU(s) list:   0-31
   Thread(s) per core:2
   Core(s) per socket:16
   Socket(s): 1
   NUMA node(s):  1
   Vendor ID: GenuineIntel
   CPU family:6
   Model: 79
   Model name:Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
   Stepping:  1
   CPU MHz:   2692.707
   CPU max MHz:   3000.
   CPU min MHz:   1200.
   BogoMIPS:  4600.08
   Hypervisor vendor: Xen
   Virtualization type:   full
   L1d cache: 32K
   L1i cache: 32K
   L2 cache:  256K
   L3 cache:  46080K
   NUMA node0 CPU(s): 0-31
   Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge 
mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx pdpe1gb rdtscp lm 
constant_tsc rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni 
pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt 
tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 
3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx 
xsaveopt
   --Network Test--
   Setting timeout: 10
   Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0023 
sec, LOAD: 0.4079 sec.
   Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.1372 sec, LOAD: 
0.1955 sec.
   Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.1189 sec, LOAD: 
0.3464 sec.
   Timing for FashionMNIST: 
https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz,
 DNS: 0.0170 sec, LOAD: 0.3851 sec.
   Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0037 sec, LOAD: 
0.2626 sec.
   Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0098 sec, 
LOAD: 0.0693 sec.
   ```
   
   Package used: Python 3.6
   
   ## Steps to reproduce
   ```
   python lstm_ocr.py
   ```
   
   ## What have you tried to solve it?
   The bottleneck is the captcha image generation. I can get to ~4200 samples 
per second speed using one k80 GPU by feeding the same image. By modifying the 
script and using multiprocessing library to generate images using 16 processes 
on a P2.8x EC2 instance with 16 CPUs, I can generate ~3000 images per second.
   - What configuration was used for the the training session shown in the 
README?
   


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


[GitHub] ptrendx commented on issue #9193: How to use nccl kvstore

2017-12-27 Thread GitBox
ptrendx commented on issue #9193: How to use nccl kvstore
URL: 
https://github.com/apache/incubator-mxnet/issues/9193#issuecomment-354210512
 
 
   @solin319 Could you try NCCL 2? NCCL 1 is no longer under  active 
development and could contain bugs.


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


[GitHub] safrooze opened a new issue #9213: Crash when MXNet API called before spawning multiprocess

2017-12-27 Thread GitBox
safrooze opened a new issue #9213: Crash when MXNet API called before spawning 
multiprocess
URL: https://github.com/apache/incubator-mxnet/issues/9213
 
 
   ## Description
   When any MXNet API is called before spawning new processes using python 
multiprocess, the main process crashes.
   
   ## Environment info (Required)
   Python 2.7
   ```
   --Python Info--
   ('Version  :', '2.7.14')
   ('Compiler :', 'GCC 7.2.0')
   ('Build:', ('default', 'Dec  4 2017 23:37:59'))
   ('Arch :', ('64bit', ''))
   Pip Info---
   ('Version  :', '9.0.1')
   ('Directory:', 
'/home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/pip')
   --MXNet Info---
   ('Version  :', '1.0.0')
   ('Directory:', 
'/home/ubuntu/anaconda3/envs/mxnet_p27/lib/python2.7/site-packages/mxnet')
   ('Commit Hash   :', '2b67436802b750e15b9fbfdf275958c1000be6a8')
   --System Info--
   ('Platform :', 'Linux-4.4.0-1044-aws-x86_64-with-debian-stretch-sid')
   ('system   :', 'Linux')
   ('node :', 'ip-172-31-32-80')
   ('release  :', '4.4.0-1044-aws')
   ('version  :', '#53-Ubuntu SMP Mon Dec 11 13:49:57 UTC 2017')
   --Hardware Info--
   ('machine  :', 'x86_64')
   ('processor:', 'x86_64')
   Architecture:  x86_64
   CPU op-mode(s):32-bit, 64-bit
   Byte Order:Little Endian
   CPU(s):32
   On-line CPU(s) list:   0-31
   Thread(s) per core:2
   Core(s) per socket:16
   Socket(s): 1
   NUMA node(s):  1
   Vendor ID: GenuineIntel
   CPU family:6
   Model: 79
   Model name:Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
   Stepping:  1
   CPU MHz:   2699.984
   CPU max MHz:   3000.
   CPU min MHz:   1200.
   BogoMIPS:  4600.08
   Hypervisor vendor: Xen
   Virtualization type:   full
   L1d cache: 32K
   L1i cache: 32K
   L2 cache:  256K
   L3 cache:  46080K
   NUMA node0 CPU(s): 0-31
   Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge 
mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx pdpe1gb rdtscp lm 
constant_tsc rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni 
pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt 
tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 
3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx 
xsaveopt
   --Network Test--
   Setting timeout: 10
   Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0020 
sec, LOAD: 0.4464 sec.
   Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0033 sec, LOAD: 
0.1646 sec.
   Timing for FashionMNIST: 
https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz,
 DNS: 0.0233 sec, LOAD: 0.4099 sec.
   Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0015 sec, 
LOAD: 0.0386 sec.
   Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0430 sec, LOAD: 
0.1414 sec.
   Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.1365 sec, LOAD: 
0.3451 sec.
   ```
   Python 3.6
   ```
   --Python Info--
   Version  : 3.6.3
   Compiler : GCC 7.2.0
   Build: ('default', 'Nov 20 2017 20:41:42')
   Arch : ('64bit', '')
   Pip Info---
   Version  : 9.0.1
   Directory: 
/home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/pip
   --MXNet Info---
   Version  : 1.0.0
   Directory: 
/home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet
   Commit Hash   : 2b67436802b750e15b9fbfdf275958c1000be6a8
   --System Info--
   Platform : Linux-4.4.0-1044-aws-x86_64-with-debian-stretch-sid
   system   : Linux
   node : ip-172-31-32-80
   release  : 4.4.0-1044-aws
   version  : #53-Ubuntu SMP Mon Dec 11 13:49:57 UTC 2017
   --Hardware Info--
   machine  : x86_64
   processor: x86_64
   Architecture:  x86_64
   CPU op-mode(s):32-bit, 64-bit
   Byte Order:Little Endian
   CPU(s):32
   On-line CPU(s) list:   0-31
   Thread(s) per core:2
   Core(s) per socket:16
   Socket(s): 1
   NUMA node(s):  1
   Vendor ID: GenuineIntel
   CPU family:6
   Model: 79
   Model name:Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
   Stepping:  1
   CPU MHz:   2692.707
   CPU max MHz:   3000.
   CPU min MHz:   1200.
   BogoMIPS:  4600.08
   Hypervisor vendor: Xen
   Virtualization type:   full
   L1d cache: 32K
   L1i cache: 32K
   L2 cache: 

[GitHub] szha commented on issue #9085: Add result sections in sparse tutorials

2017-12-27 Thread GitBox
szha commented on issue #9085: Add result sections in sparse tutorials
URL: https://github.com/apache/incubator-mxnet/pull/9085#issuecomment-354207114
 
 
   @aaronmarkham ping


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


[GitHub] szha closed pull request #9027: Usability improvement for cnn_chinese_text_classification

2017-12-27 Thread GitBox
szha closed pull request #9027: Usability improvement for 
cnn_chinese_text_classification
URL: https://github.com/apache/incubator-mxnet/pull/9027
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/example/cnn_chinese_text_classification/text_cnn.py 
b/example/cnn_chinese_text_classification/text_cnn.py
index 8fd6b05ccf..2a78fd2578 100644
--- a/example/cnn_chinese_text_classification/text_cnn.py
+++ b/example/cnn_chinese_text_classification/text_cnn.py
@@ -20,13 +20,11 @@
 
 # -*- coding: utf-8 -*-
 
-import sys
-import os
+import sys, os
 import mxnet as mx
 import numpy as np
 import argparse
 import logging
-
 import time
 
 from mxnet import random
@@ -35,7 +33,7 @@
 import data_helpers
 
 fmt = '%(asctime)s:filename %(filename)s: lineno 
%(lineno)d:%(levelname)s:%(message)s'
-logging.basicConfig(format=fmt, filemode='a+', 
filename='./cnn_text_classification.log', level=logging.DEBUG)
+logging.basicConfig(format=fmt, stream=sys.stdout, level=logging.DEBUG)
 logger = logging.getLogger(__name__)
 
 parser = argparse.ArgumentParser(description="CNN for text classification",
diff --git a/example/cnn_text_classification/old/text_cnn.py 
b/example/cnn_text_classification/old/text_cnn.py
deleted file mode 100644
index 8d82d6ef79..00
--- a/example/cnn_text_classification/old/text_cnn.py
+++ /dev/null
@@ -1,279 +0,0 @@
-#!/usr/bin/env python
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# -*- coding: utf-8 -*-
-from __future__ import print_function
-import sys,os
-import mxnet as mx
-import numpy as np
-import time
-import math
-import data_helpers
-from collections import namedtuple
-
-import logging
-logging.basicConfig(level=logging.INFO)
-logger = logging.getLogger(__name__) # get a logger to accuracies are printed
-
-logs = sys.stderr
-
-CNNModel = namedtuple("CNNModel", ['cnn_exec', 'symbol', 'data', 'label', 
'param_blocks'])
-
-def make_text_cnn(sentence_size, num_embed, batch_size, vocab_size,
-num_label=2, filter_list=[3, 4, 5], num_filter=100,
-dropout=0., with_embedding=True):
-
-input_x = mx.sym.Variable('data') # placeholder for input
-input_y = mx.sym.Variable('softmax_label') # placeholder for output
-
-# embedding layer
-if not with_embedding:
-embed_layer = mx.sym.Embedding(data=input_x, input_dim=vocab_size, 
output_dim=num_embed, name='vocab_embed')
-conv_input = mx.sym.Reshape(data=embed_layer, 
target_shape=(batch_size, 1, sentence_size, num_embed))
-else:
-conv_input = input_x
-
-# create convolution + (max) pooling layer for each filter operation
-pooled_outputs = []
-for i, filter_size in enumerate(filter_list):
-convi = mx.sym.Convolution(data=conv_input, kernel=(filter_size, 
num_embed), num_filter=num_filter)
-relui = mx.sym.Activation(data=convi, act_type='relu')
-pooli = mx.sym.Pooling(data=relui, pool_type='max', 
kernel=(sentence_size - filter_size + 1, 1), stride=(1,1))
-pooled_outputs.append(pooli)
-
-# combine all pooled outputs
-total_filters = num_filter * len(filter_list)
-concat = mx.sym.Concat(*pooled_outputs, dim=1)
-h_pool = mx.sym.Reshape(data=concat, target_shape=(batch_size, 
total_filters))
-
-# dropout layer
-if dropout > 0.0:
-h_drop = mx.sym.Dropout(data=h_pool, p=dropout)
-else:
-h_drop = h_pool
-
-# fully connected
-cls_weight = mx.sym.Variable('cls_weight')
-cls_bias = mx.sym.Variable('cls_bias')
-
-fc = mx.sym.FullyConnected(data=h_drop, weight=cls_weight, bias=cls_bias, 
num_hidden=num_label)
-
-# softmax output
-sm = mx.sym.SoftmaxOutput(data=fc, label=input_y, name='softmax')
-
-return sm
-
-
-def setup_cnn_model(ctx, batch_size, sentence_size, num_embed, vocab_size,
-dropout=0.5, initializer=mx.initializer.Uniform(0.1), 
with_embedding=True):
-
-cnn = make_text_cnn(sentence_size, num_embed, batch_size=batch_size,
-vocab_size=vocab_size, dropout=dropout, 

[incubator-mxnet] branch master updated: Usability improvement for cnn_chinese_text_classification (#9027)

2017-12-27 Thread zhasheng
This is an automated email from the ASF dual-hosted git repository.

zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new 7f1dd77  Usability improvement for cnn_chinese_text_classification 
(#9027)
7f1dd77 is described below

commit 7f1dd772675544e333c438716a826b82d7c4cf94
Author: Haibin Lin 
AuthorDate: Wed Dec 27 16:54:32 2017 -0800

Usability improvement for cnn_chinese_text_classification (#9027)

* Update text_cnn.py

* Delete text_cnn.py

* Update text_cnn.py

* log to stdout
---
 .../cnn_chinese_text_classification/text_cnn.py|   6 +-
 example/cnn_text_classification/old/text_cnn.py| 279 -
 2 files changed, 2 insertions(+), 283 deletions(-)

diff --git a/example/cnn_chinese_text_classification/text_cnn.py 
b/example/cnn_chinese_text_classification/text_cnn.py
index 8fd6b05..2a78fd2 100644
--- a/example/cnn_chinese_text_classification/text_cnn.py
+++ b/example/cnn_chinese_text_classification/text_cnn.py
@@ -20,13 +20,11 @@
 
 # -*- coding: utf-8 -*-
 
-import sys
-import os
+import sys, os
 import mxnet as mx
 import numpy as np
 import argparse
 import logging
-
 import time
 
 from mxnet import random
@@ -35,7 +33,7 @@ from mxnet.initializer import Xavier, Initializer
 import data_helpers
 
 fmt = '%(asctime)s:filename %(filename)s: lineno 
%(lineno)d:%(levelname)s:%(message)s'
-logging.basicConfig(format=fmt, filemode='a+', 
filename='./cnn_text_classification.log', level=logging.DEBUG)
+logging.basicConfig(format=fmt, stream=sys.stdout, level=logging.DEBUG)
 logger = logging.getLogger(__name__)
 
 parser = argparse.ArgumentParser(description="CNN for text classification",
diff --git a/example/cnn_text_classification/old/text_cnn.py 
b/example/cnn_text_classification/old/text_cnn.py
deleted file mode 100644
index 8d82d6e..000
--- a/example/cnn_text_classification/old/text_cnn.py
+++ /dev/null
@@ -1,279 +0,0 @@
-#!/usr/bin/env python
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# -*- coding: utf-8 -*-
-from __future__ import print_function
-import sys,os
-import mxnet as mx
-import numpy as np
-import time
-import math
-import data_helpers
-from collections import namedtuple
-
-import logging
-logging.basicConfig(level=logging.INFO)
-logger = logging.getLogger(__name__) # get a logger to accuracies are printed
-
-logs = sys.stderr
-
-CNNModel = namedtuple("CNNModel", ['cnn_exec', 'symbol', 'data', 'label', 
'param_blocks'])
-
-def make_text_cnn(sentence_size, num_embed, batch_size, vocab_size,
-num_label=2, filter_list=[3, 4, 5], num_filter=100,
-dropout=0., with_embedding=True):
-
-input_x = mx.sym.Variable('data') # placeholder for input
-input_y = mx.sym.Variable('softmax_label') # placeholder for output
-
-# embedding layer
-if not with_embedding:
-embed_layer = mx.sym.Embedding(data=input_x, input_dim=vocab_size, 
output_dim=num_embed, name='vocab_embed')
-conv_input = mx.sym.Reshape(data=embed_layer, 
target_shape=(batch_size, 1, sentence_size, num_embed))
-else:
-conv_input = input_x
-
-# create convolution + (max) pooling layer for each filter operation
-pooled_outputs = []
-for i, filter_size in enumerate(filter_list):
-convi = mx.sym.Convolution(data=conv_input, kernel=(filter_size, 
num_embed), num_filter=num_filter)
-relui = mx.sym.Activation(data=convi, act_type='relu')
-pooli = mx.sym.Pooling(data=relui, pool_type='max', 
kernel=(sentence_size - filter_size + 1, 1), stride=(1,1))
-pooled_outputs.append(pooli)
-
-# combine all pooled outputs
-total_filters = num_filter * len(filter_list)
-concat = mx.sym.Concat(*pooled_outputs, dim=1)
-h_pool = mx.sym.Reshape(data=concat, target_shape=(batch_size, 
total_filters))
-
-# dropout layer
-if dropout > 0.0:
-h_drop = mx.sym.Dropout(data=h_pool, p=dropout)
-else:
-h_drop = h_pool
-
-# fully connected
-cls_weight = mx.sym.Variable('cls_weight')
-cls_bias = mx.sym.Variable('cls_bias')
-
-fc = 

[GitHub] szha commented on issue #7960: Dropout layer crashes jupyter kernel

2017-12-27 Thread GitBox
szha commented on issue #7960: Dropout layer crashes jupyter kernel
URL: 
https://github.com/apache/incubator-mxnet/issues/7960#issuecomment-354203093
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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


[GitHub] szha commented on issue #7918: How to use the sample_weight parameter of SoftmaxCrossEntropyLoss?

2017-12-27 Thread GitBox
szha commented on issue #7918: How to use the sample_weight parameter of 
SoftmaxCrossEntropyLoss?
URL: 
https://github.com/apache/incubator-mxnet/issues/7918#issuecomment-354203101
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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


[GitHub] eric-haibin-lin commented on issue #9193: How to use nccl kvstore

2017-12-27 Thread GitBox
eric-haibin-lin commented on issue #9193: How to use nccl kvstore
URL: 
https://github.com/apache/incubator-mxnet/issues/9193#issuecomment-354198562
 
 
   @ptrendx 


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


[GitHub] eric-haibin-lin commented on issue #9197: Get a element of tensor

2017-12-27 Thread GitBox
eric-haibin-lin commented on issue #9197: Get a element of tensor
URL: 
https://github.com/apache/incubator-mxnet/issues/9197#issuecomment-354196503
 
 
   `Tensor labels ` is a 2-D tensor. labels[i][j] should return the 
`real_t` element at position (i,j)


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


[GitHub] eric-haibin-lin commented on a change in pull request #9027: Usability improvement for cnn_chinese_text_classification

2017-12-27 Thread GitBox
eric-haibin-lin commented on a change in pull request #9027: Usability 
improvement for cnn_chinese_text_classification
URL: https://github.com/apache/incubator-mxnet/pull/9027#discussion_r158880130
 
 

 ##
 File path: example/cnn_chinese_text_classification/text_cnn.py
 ##
 @@ -20,20 +20,19 @@
 
 # -*- coding: utf-8 -*-
 
-import sys
-import os
+import sys, os
 import mxnet as mx
 import numpy as np
 import argparse
 import logging
-
 import time
 
 from mxnet import random
 from mxnet.initializer import Xavier, Initializer
 
 import data_helpers
 
+print("The training log can be found at ./cnn_text_classification.log")
 
 Review comment:
   updated to stdout now


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


[GitHub] eric-haibin-lin commented on a change in pull request #9073: Updating the README files and examples in "ctc" and "recommenders" folder.

2017-12-27 Thread GitBox
eric-haibin-lin commented on a change in pull request #9073: Updating the 
README files and examples in "ctc" and "recommenders" folder.
URL: https://github.com/apache/incubator-mxnet/pull/9073#discussion_r158878842
 
 

 ##
 File path: example/ctc/README.md
 ##
 @@ -49,68 +55,26 @@ def lstm_unroll(num_lstm_layer, seq_len,
 
 return mx.sym.Group([softmax_loss, ctc_loss])
 ```
-# Some Result
-If there were more training, the result would be better
 
+## Prerequisites
+
+Please ensure that following prerequisites are satisfied before running this 
examples.
+
+- ```captcha``` python package is installed.
+- ```cv2``` (or ```openCV```) python package is installed.
+- The test requires font file (```ttf``` format). The user either would need 
to create ```.\data\```  directory and place the font file in that directory. 
The user can also edit following line to specify path to the font file.
+```cython
+# you can get this font from http://font.ubuntu.com/
+self.captcha = ImageCaptcha(fonts=['./data/Xerox.ttf'])
 ```
-2017-07-08 13:22:01,155 Epoch[94] Batch [50]Speed: 4273.43 samples/sec 
Accuracy=0.808747
-2017-07-08 13:22:13,141 Epoch[94] Batch [100]  Speed: 4271.84 samples/sec  
Accuracy=0.786855
-2017-07-08 13:22:25,179 Epoch[94] Batch [150]  Speed: 4253.81 samples/sec  
Accuracy=0.810625
-2017-07-08 13:22:37,198 Epoch[94] Batch [200]  Speed: 4259.96 samples/sec  
Accuracy=0.808809
-2017-07-08 13:22:49,233 Epoch[94] Batch [250]  Speed: 4254.13 samples/sec  
Accuracy=0.806426
-2017-07-08 13:23:01,308 Epoch[94] Batch [300]  Speed: 4239.98 samples/sec  
Accuracy=0.817305
-2017-07-08 13:23:02,030 Epoch[94] Train-Accuracy=0.819336
-2017-07-08 13:23:02,030 Epoch[94] Time cost=73.092
-2017-07-08 13:23:02,101 Saved checkpoint to "ocr-0095.params"
-2017-07-08 13:23:07,192 Epoch[94] Validation-Accuracy=0.819417
-2017-07-08 13:23:20,579 Epoch[95] Batch [50]   Speed: 4288.76 samples/sec  
Accuracy=0.817459
-2017-07-08 13:23:32,573 Epoch[95] Batch [100]  Speed: 4268.75 samples/sec  
Accuracy=0.815215
-2017-07-08 13:23:44,635 Epoch[95] Batch [150]  Speed: 4244.85 samples/sec  
Accuracy=0.820215
-2017-07-08 13:23:56,670 Epoch[95] Batch [200]  Speed: 4254.38 samples/sec  
Accuracy=0.823613
-2017-07-08 13:24:08,650 Epoch[95] Batch [250]  Speed: 4273.83 samples/sec  
Accuracy=0.827109
-2017-07-08 13:24:20,680 Epoch[95] Batch [300]  Speed: 4256.49 samples/sec  
Accuracy=0.824961
-2017-07-08 13:24:21,401 Epoch[95] Train-Accuracy=0.840495
-2017-07-08 13:24:21,401 Epoch[95] Time cost=73.008
-2017-07-08 13:24:21,441 Saved checkpoint to "ocr-0096.params"
-2017-07-08 13:24:26,508 Epoch[95] Validation-Accuracy=0.834798
-2017-07-08 13:24:39,938 Epoch[96] Batch [50]   Speed: 4259.32 samples/sec  
Accuracy=0.825578
-2017-07-08 13:24:51,987 Epoch[96] Batch [100]  Speed: 4249.67 samples/sec  
Accuracy=0.826562
-2017-07-08 13:25:04,041 Epoch[96] Batch [150]  Speed: 4247.44 samples/sec  
Accuracy=0.831855
-2017-07-08 13:25:16,058 Epoch[96] Batch [200]  Speed: 4260.77 samples/sec  
Accuracy=0.830840
-2017-07-08 13:25:28,109 Epoch[96] Batch [250]  Speed: 4248.44 samples/sec  
Accuracy=0.827168
-2017-07-08 13:25:40,057 Epoch[96] Batch [300]  Speed: 4285.23 samples/sec  
Accuracy=0.832715
-2017-07-08 13:25:40,782 Epoch[96] Train-Accuracy=0.830729
-2017-07-08 13:25:40,782 Epoch[96] Time cost=73.098
-2017-07-08 13:25:40,821 Saved checkpoint to "ocr-0097.params"
-2017-07-08 13:25:45,886 Epoch[96] Validation-Accuracy=0.840820
-2017-07-08 13:25:59,283 Epoch[97] Batch [50]   Speed: 4271.85 samples/sec  
Accuracy=0.831648
-2017-07-08 13:26:11,243 Epoch[97] Batch [100]  Speed: 4280.89 samples/sec  
Accuracy=0.835371
-2017-07-08 13:26:23,263 Epoch[97] Batch [150]  Speed: 4259.89 samples/sec  
Accuracy=0.831094
-2017-07-08 13:26:35,230 Epoch[97] Batch [200]  Speed: 4278.40 samples/sec  
Accuracy=0.827129
-2017-07-08 13:26:47,199 Epoch[97] Batch [250]  Speed: 4277.77 samples/sec  
Accuracy=0.834258
-2017-07-08 13:26:59,257 Epoch[97] Batch [300]  Speed: 4245.93 samples/sec  
Accuracy=0.833770
-2017-07-08 13:26:59,971 Epoch[97] Train-Accuracy=0.844727
-2017-07-08 13:26:59,971 Epoch[97] Time cost=72.908
-2017-07-08 13:27:00,020 Saved checkpoint to "ocr-0098.params"
-2017-07-08 13:27:05,130 Epoch[97] Validation-Accuracy=0.827962
-2017-07-08 13:27:18,521 Epoch[98] Batch [50]   Speed: 4281.06 samples/sec  
Accuracy=0.834118
-2017-07-08 13:27:30,537 Epoch[98] Batch [100]  Speed: 4261.20 samples/sec  
Accuracy=0.835352
-2017-07-08 13:27:42,542 Epoch[98] Batch [150]  Speed: 4264.88 samples/sec  
Accuracy=0.839395
-2017-07-08 13:27:54,544 Epoch[98] Batch [200]  Speed: 4266.31 samples/sec  
Accuracy=0.836328
-2017-07-08 13:28:06,550 Epoch[98] Batch [250]  Speed: 4264.50 samples/sec  
Accuracy=0.841465
-2017-07-08 13:28:18,622 Epoch[98] Batch [300]  Speed: 4241.11 samples/sec  
Accuracy=0.831680
-2017-07-08 

[GitHub] reminisce commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
reminisce commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158877704
 
 

 ##
 File path: src/operator/tensor/indexing_op.cc
 ##
 @@ -137,6 +137,26 @@ inline void SparseEmbeddingOpBackwardRspImpl(const 
OpContext& ctx,
 }
 
 
+template
+inline void ScatterNDAccForwardImpl(int N, int M, int K,
+const mshadow::Shape<10> strides,
+DType* out,
+const DType* data,
+const IType* indices,
+mshadow::Stream *s) {
+#pragma omp parallel for
+  for (int i = 0; i < N; i++) {
+int offset = 0;
+for (int j = 0; j < M; ++j) {
+  offset += strides[j] * static_cast(indices[j*N + i]);
+}
+for (int j = 0; j < K; ++j) {
+#pragma omp atomic
+  out[offset + j] += data[i * K + j];
 
 Review comment:
   You can consolidate this with the gpu kernel by using `#if __CUDA__ #else`in 
the header file since this line is the only difference between cpu and gpu 
kernels. Then in the `FCompute` function, you can use `Kernel::Launch` for both 
cpu and gpu kernels. That would make the implementation less verbose.


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


[GitHub] marcoabreu commented on issue #9129: add tests for distribution generators

2017-12-27 Thread GitBox
marcoabreu commented on issue #9129: add tests for distribution generators
URL: https://github.com/apache/incubator-mxnet/pull/9129#issuecomment-354188385
 
 
   Okay, thank you. I don't think scipi is installed inside our test 
environments so your PR may fail until we added a proper dependency management 
for CI. I will notify you as soon as this has been added.


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


[GitHub] sxjscience commented on issue #9129: add tests for distribution generators

2017-12-27 Thread GitBox
sxjscience commented on issue #9129: add tests for distribution generators
URL: https://github.com/apache/incubator-mxnet/pull/9129#issuecomment-354186669
 
 
   @marcoabreu Yes, should be an error.


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


[GitHub] sxjscience commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
sxjscience commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158875264
 
 

 ##
 File path: src/operator/tensor/indexing_op.cu
 ##
 @@ -179,6 +179,37 @@ inline void SparseEmbeddingOpBackwardRspImpl(const 
OpContext& ctx,
   });
 }
 
+template
+__global__ void ScatterNDAccForwardImplKernel(int N, int M, int K,
+ const mshadow::Shape<10> strides,
+ DType* out,
+ const DType* data,
+ const IType* indices) {
+  for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * 
gridDim.x) {
+int offset = 0;
+for (int j = 0; j < M; ++j) {
+  offset += strides[j] * static_cast(indices[j*N + i]);
+}
+for (int j = 0; j < K; ++j) {
+  atomicAdd(out + (offset + j), data[i * K + j]);
+}
+  }
+}
+
+template
+inline void ScatterNDAccForwardImpl(int N, int M, int K,
+const mshadow::Shape<10> strides,
+DType* out,
+const DType* data,
+const IType* indices,
+mshadow::Stream *s) {
+  using namespace mshadow::cuda;
+  int ngrid = std::min(kMaxGridNum, (N + kBaseThreadNum - 1) / kBaseThreadNum);
+  ScatterNDAccForwardImplKernel
 
 Review comment:
   Okay, I can still use launch, but can only use it for GPU.


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


[GitHub] marcoabreu commented on issue #9129: add tests for distribution generators

2017-12-27 Thread GitBox
marcoabreu commented on issue #9129: add tests for distribution generators
URL: https://github.com/apache/incubator-mxnet/pull/9129#issuecomment-354185984
 
 
   For tests, please throw an error instead of a warning if a dependency is not 
present. 


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


[GitHub] reminisce commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
reminisce commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158874779
 
 

 ##
 File path: src/operator/tensor/indexing_op.cu
 ##
 @@ -179,6 +179,37 @@ inline void SparseEmbeddingOpBackwardRspImpl(const 
OpContext& ctx,
   });
 }
 
+template
+__global__ void ScatterNDAccForwardImplKernel(int N, int M, int K,
+ const mshadow::Shape<10> strides,
+ DType* out,
+ const DType* data,
+ const IType* indices) {
+  for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * 
gridDim.x) {
+int offset = 0;
+for (int j = 0; j < M; ++j) {
+  offset += strides[j] * static_cast(indices[j*N + i]);
+}
+for (int j = 0; j < K; ++j) {
+  atomicAdd(out + (offset + j), data[i * K + j]);
+}
+  }
+}
+
+template
+inline void ScatterNDAccForwardImpl(int N, int M, int K,
+const mshadow::Shape<10> strides,
+DType* out,
+const DType* data,
+const IType* indices,
+mshadow::Stream *s) {
+  using namespace mshadow::cuda;
+  int ngrid = std::min(kMaxGridNum, (N + kBaseThreadNum - 1) / kBaseThreadNum);
+  ScatterNDAccForwardImplKernel
 
 Review comment:
   Why does `atomicAdd` prevent `Kernel::Launch` from being used?


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


[GitHub] sxjscience commented on issue #9129: add tests for distribution generators

2017-12-27 Thread GitBox
sxjscience commented on issue #9129: add tests for distribution generators
URL: https://github.com/apache/incubator-mxnet/pull/9129#issuecomment-354185234
 
 
   @marcoabreu I'm following the implementation of ndarray.sparse 
(https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/ndarray/sparse.py#L58-L61).
 However, I should raise a warning if ss is not found.


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


[GitHub] sxjscience commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
sxjscience commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158874022
 
 

 ##
 File path: src/operator/tensor/indexing_op.cc
 ##
 @@ -137,6 +137,24 @@ inline void SparseEmbeddingOpBackwardRspImpl(const 
OpContext& ctx,
 }
 
 
+template
+inline void ScatterNDAccForwardImpl(int N, int M, int K,
+const mshadow::Shape<10> strides,
+DType* out,
+const DType* data,
+const IType* indices,
+mshadow::Stream *s) {
+  for (int i = 0; i < N; i++) {
 
 Review comment:
   Yes, we can use openmp. Let me have a try.


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


[GitHub] sxjscience commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
sxjscience commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158873667
 
 

 ##
 File path: src/operator/tensor/indexing_op.cu
 ##
 @@ -209,6 +240,9 @@ NNVM_REGISTER_OP(gather_nd)
 NNVM_REGISTER_OP(scatter_nd)
 .set_attr("FCompute", ScatterNDForward);
 
+NNVM_REGISTER_OP(scatter_nd_acc)
 
 Review comment:
   There is a slight difference between `scatter_nd_add` and `scatter_nd_acc`. 
In scatter_nd_add, the results are added to another array. While in 
scatter_nd_acc, the values are added to a all-zero array. The number of 
arguments are different for these two OPs.


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


[GitHub] sxjscience commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
sxjscience commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158873217
 
 

 ##
 File path: src/operator/tensor/indexing_op.cu
 ##
 @@ -179,6 +179,37 @@ inline void SparseEmbeddingOpBackwardRspImpl(const 
OpContext& ctx,
   });
 }
 
+template
+__global__ void ScatterNDAccForwardImplKernel(int N, int M, int K,
+ const mshadow::Shape<10> strides,
+ DType* out,
+ const DType* data,
+ const IType* indices) {
+  for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * 
gridDim.x) {
+int offset = 0;
+for (int j = 0; j < M; ++j) {
+  offset += strides[j] * static_cast(indices[j*N + i]);
+}
+for (int j = 0; j < K; ++j) {
+  atomicAdd(out + (offset + j), data[i * K + j]);
+}
+  }
+}
+
+template
+inline void ScatterNDAccForwardImpl(int N, int M, int K,
+const mshadow::Shape<10> strides,
+DType* out,
+const DType* data,
+const IType* indices,
+mshadow::Stream *s) {
+  using namespace mshadow::cuda;
+  int ngrid = std::min(kMaxGridNum, (N + kBaseThreadNum - 1) / kBaseThreadNum);
+  ScatterNDAccForwardImplKernel
 
 Review comment:
   It does not fit due to the atomicAdd.


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


[GitHub] reminisce commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
reminisce commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158859124
 
 

 ##
 File path: src/operator/tensor/indexing_op.cc
 ##
 @@ -137,6 +137,24 @@ inline void SparseEmbeddingOpBackwardRspImpl(const 
OpContext& ctx,
 }
 
 
+template
+inline void ScatterNDAccForwardImpl(int N, int M, int K,
+const mshadow::Shape<10> strides,
+DType* out,
+const DType* data,
+const IType* indices,
+mshadow::Stream *s) {
+  for (int i = 0; i < N; i++) {
 
 Review comment:
   This is single-threaded. Can we use `#pragma omp critical` or `#pragma omp 
atomic` for the cpu kernel?


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


[GitHub] reminisce commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
reminisce commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158871673
 
 

 ##
 File path: src/operator/tensor/indexing_op.cu
 ##
 @@ -209,6 +240,9 @@ NNVM_REGISTER_OP(gather_nd)
 NNVM_REGISTER_OP(scatter_nd)
 .set_attr("FCompute", ScatterNDForward);
 
+NNVM_REGISTER_OP(scatter_nd_acc)
 
 Review comment:
   The string `acc` looks ambiguous. I thought it standed for `accurate` in the 
beginning, but realized that it means `accumulate` later. It's named 
`scatter_nd_add` in TF, as there are also `scatter_nd_sub`, `scatter_nd_mul`, 
and `scatter_nd_div`. Shall we also call it `scatter_nd_add` to be precise?


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


[GitHub] reminisce commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
reminisce commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158872417
 
 

 ##
 File path: src/operator/tensor/indexing_op.cu
 ##
 @@ -179,6 +179,37 @@ inline void SparseEmbeddingOpBackwardRspImpl(const 
OpContext& ctx,
   });
 }
 
+template
+__global__ void ScatterNDAccForwardImplKernel(int N, int M, int K,
+ const mshadow::Shape<10> strides,
 
 Review comment:
   Indent.


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


[GitHub] reminisce commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
reminisce commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158872235
 
 

 ##
 File path: src/operator/tensor/indexing_op.cu
 ##
 @@ -179,6 +179,37 @@ inline void SparseEmbeddingOpBackwardRspImpl(const 
OpContext& ctx,
   });
 }
 
+template
+__global__ void ScatterNDAccForwardImplKernel(int N, int M, int K,
+ const mshadow::Shape<10> strides,
+ DType* out,
+ const DType* data,
+ const IType* indices) {
+  for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * 
gridDim.x) {
+int offset = 0;
+for (int j = 0; j < M; ++j) {
+  offset += strides[j] * static_cast(indices[j*N + i]);
+}
+for (int j = 0; j < K; ++j) {
+  atomicAdd(out + (offset + j), data[i * K + j]);
+}
+  }
+}
+
+template
+inline void ScatterNDAccForwardImpl(int N, int M, int K,
+const mshadow::Shape<10> strides,
+DType* out,
+const DType* data,
+const IType* indices,
+mshadow::Stream *s) {
+  using namespace mshadow::cuda;
+  int ngrid = std::min(kMaxGridNum, (N + kBaseThreadNum - 1) / kBaseThreadNum);
+  ScatterNDAccForwardImplKernel
 
 Review comment:
   Does `Kernel::Launch` not fit here?


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


[GitHub] safrooze opened a new pull request #9212: Modified nce-loss README to use image files in dmlc/web-data repo

2017-12-27 Thread GitBox
safrooze opened a new pull request #9212: Modified nce-loss README to use image 
files in dmlc/web-data repo
URL: https://github.com/apache/incubator-mxnet/pull/9212
 
 
   ## Description ##
   Previously README in nce-loss example referenced a user repo. Modified the 
file to use image file in dmlc/web-data repo.
   
   ## Checklist ##
   ### Essentials ###
   - [x] Passed code style checking (`make lint`)
   - [x] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage: N/A
   - [ ] Code is well-documented: N/A
   - [x] To the my best knowledge, examples are either not affected by this 
change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [x] README fix to reference image URL in dmlc/web-data
   


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


[GitHub] sxjscience commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
sxjscience commented on a change in pull request #9119: fix random generator: 
do not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158868361
 
 

 ##
 File path: python/mxnet/test_utils.py
 ##
 @@ -34,6 +34,7 @@
 import numpy as np
 import numpy.testing as npt
 import numpy.random as rnd
+import scipy.stats as ss
 
 Review comment:
   @javelinjs @piiswrong I've added one commit to solve the problem. Also, 
I also add tests for the case in which the generator is triggered multiple 
times. 
https://github.com/apache/incubator-mxnet/pull/9129/commits/199fabdcc06736393f63639a806f522454341d02


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


[GitHub] bejjani commented on issue #9210: Cosine Loss: Formula

2017-12-27 Thread GitBox
bejjani commented on issue #9210: Cosine Loss: Formula
URL: 
https://github.com/apache/incubator-mxnet/issues/9210#issuecomment-354177010
 
 
   in order to bound it between 0 and 1 the cosine should be divided by 2
   ```python
   cosine = cosine / 2
   ```


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


[GitHub] kalpitdixit commented on issue #9171: MXNet: Using FusedRNNCell with its "bidirectional" flag turned True, can lead to hanging of training run.

2017-12-27 Thread GitBox
kalpitdixit commented on issue #9171: MXNet: Using FusedRNNCell with its 
"bidirectional" flag turned True, can lead to hanging of training run.
URL: 
https://github.com/apache/incubator-mxnet/issues/9171#issuecomment-354172077
 
 
   @szha 
   I tested CUDA 9.0.176 with cuDNN 7.0.3  and with cuDNN 7.0.5.
   In both cases, the hanging problem happens.
   


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


[incubator-mxnet] branch master updated: refactor graph exec (#9122)

2017-12-27 Thread jxie
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new be40d31  refactor graph exec (#9122)
be40d31 is described below

commit be40d31b9663cc201e63125f48a6b51d094ad9ce
Author: Pedro Larroy <928489+lar...@users.noreply.github.com>
AuthorDate: Wed Dec 27 21:18:06 2017 +0100

refactor graph exec (#9122)
---
 src/executor/graph_executor.cc | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/executor/graph_executor.cc b/src/executor/graph_executor.cc
index 6afb1a6..77853a6 100644
--- a/src/executor/graph_executor.cc
+++ b/src/executor/graph_executor.cc
@@ -157,7 +157,7 @@ nnvm::NodeEntry 
AggregateGradient(std::vector&& v) {
   static const Op* zeros_op = Op::Get("_zeros");
   static const Op* zeros_like_op = Op::Get("zeros_like");
 
-  if (v.size() == 0) {
+  if (v.empty()) {
 nnvm::NodePtr ng = nnvm::Node::Create();
 ng->attrs.op = zeros_op;
 ng->attrs.name = "zeros";
@@ -166,17 +166,12 @@ nnvm::NodeEntry 
AggregateGradient(std::vector&& v) {
   }
 
   // remove zero in the sum. at least keep 1.
-  size_t begin = 0;
-  for (size_t i = 0; i < v.size(); ++i) {
-if (v[i].node->op() != zeros_op && v[i].node->op() != zeros_like_op) {
-  if (begin != i) {
-v[begin] = std::move(v[i]);
-  }
-  ++begin;
-}
-  }
-  if (begin == 0) begin = 1;
-  v.resize(begin);
+  auto begin = std::remove_if(v.begin(), v.end(), [](const nnvm::NodeEntry& 
nodeEntry) {
+ return nodeEntry.node->op() == zeros_op || nodeEntry.node->op() == 
zeros_like_op;
+  });
+  if (begin == v.begin()) ++begin;
+  v.erase(begin, v.end());
+  CHECK(!v.empty());
 
   if (v.size() == 1) {
 return std::move(v[0]);

-- 
To stop receiving notification emails like this one, please contact
['"comm...@mxnet.apache.org" '].


[GitHub] piiswrong closed pull request #9122: [WIP] refactor graph exec

2017-12-27 Thread GitBox
piiswrong closed pull request #9122: [WIP] refactor graph exec
URL: https://github.com/apache/incubator-mxnet/pull/9122
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/executor/graph_executor.cc b/src/executor/graph_executor.cc
index 6afb1a6f8e..77853a61ca 100644
--- a/src/executor/graph_executor.cc
+++ b/src/executor/graph_executor.cc
@@ -157,7 +157,7 @@ nnvm::NodeEntry 
AggregateGradient(std::vector&& v) {
   static const Op* zeros_op = Op::Get("_zeros");
   static const Op* zeros_like_op = Op::Get("zeros_like");
 
-  if (v.size() == 0) {
+  if (v.empty()) {
 nnvm::NodePtr ng = nnvm::Node::Create();
 ng->attrs.op = zeros_op;
 ng->attrs.name = "zeros";
@@ -166,17 +166,12 @@ nnvm::NodeEntry 
AggregateGradient(std::vector&& v) {
   }
 
   // remove zero in the sum. at least keep 1.
-  size_t begin = 0;
-  for (size_t i = 0; i < v.size(); ++i) {
-if (v[i].node->op() != zeros_op && v[i].node->op() != zeros_like_op) {
-  if (begin != i) {
-v[begin] = std::move(v[i]);
-  }
-  ++begin;
-}
-  }
-  if (begin == 0) begin = 1;
-  v.resize(begin);
+  auto begin = std::remove_if(v.begin(), v.end(), [](const nnvm::NodeEntry& 
nodeEntry) {
+ return nodeEntry.node->op() == zeros_op || nodeEntry.node->op() == 
zeros_like_op;
+  });
+  if (begin == v.begin()) ++begin;
+  v.erase(begin, v.end());
+  CHECK(!v.empty());
 
   if (v.size() == 1) {
 return std::move(v[0]);


 


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


[GitHub] piiswrong commented on a change in pull request #9184: 1 d conv with cudnn

2017-12-27 Thread GitBox
piiswrong commented on a change in pull request #9184: 1 d conv with cudnn
URL: https://github.com/apache/incubator-mxnet/pull/9184#discussion_r158862355
 
 

 ##
 File path: src/operator/nn/convolution-inl.h
 ##
 @@ -67,13 +67,13 @@ struct ConvolutionParam : public 
dmlc::Parameter {
   bool cudnn_off;
   dmlc::optional layout;
   DMLC_DECLARE_PARAMETER(ConvolutionParam) {
-DMLC_DECLARE_FIELD(kernel).describe("Convolution kernel size: (h, w) or 
(d, h, w)");
+DMLC_DECLARE_FIELD(kernel).describe("Convolution kernel size: (h), (h, w) 
or (d, h, w)");
 DMLC_DECLARE_FIELD(stride).set_default(TShape())
-.describe("Convolution stride: (h, w) or (d, h, w). Defaults to 1 for each 
dimension.");
+.describe("Convolution stride: (h), (h, w) or (d, h, w). Defaults to 1 for 
each dimension.");
 
 Review comment:
   (h) -> (w,)


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


[incubator-mxnet] branch master updated: Install docs - update info about DLAMI (#9150)

2017-12-27 Thread jxie
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new f20a205  Install docs - update info about DLAMI (#9150)
f20a205 is described below

commit f20a205b075362be77be658c93e55f50570dc579
Author: Aaron Markham 
AuthorDate: Wed Dec 27 11:49:11 2017 -0800

Install docs - update info about DLAMI (#9150)

* changed url references from dmlc to apache/incubator-mxnet

* updated dlami info
---
 docs/install/index.md | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/docs/install/index.md b/docs/install/index.md
index dc381a5..7cdc44c 100644
--- a/docs/install/index.md
+++ b/docs/install/index.md
@@ -704,11 +704,9 @@ More details and verified installation instructions for 
macOS, with GPUs, coming
 
 
 
-AWS Marketplace distributes AMIs (Amazon Machine Image) with MXNet 
pre-installed. You can launch an Amazon EC2 instance with one of the below AMIs:
-1. Deep Learning AMI (Amazon Machine Image) for 
[Ubuntu](https://aws.amazon.com/marketplace/pp/B06VSPXKDX)
-2. Deep Learning AMI for [Amazon 
Linux](https://aws.amazon.com/marketplace/pp/B01M0AXXQB)
+AWS Marketplace distributes Deep Learning AMIs (Amazon Machine Image) with 
MXNet pre-installed. You can launch one of these Deep Learning AMIs by 
following instructions in the [AWS Deep Learning AMI Developer 
Guide](http://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html).
 
-You could also run distributed deeplearning with *MXNet* on AWS using 
[Cloudformation 
Template](https://github.com/awslabs/deeplearning-cfn/blob/master/README.md).
+You can also run distributed deep learning with *MXNet* on AWS using 
[Cloudformation 
Template](https://github.com/awslabs/deeplearning-cfn/blob/master/README.md).
 
 
 

-- 
To stop receiving notification emails like this one, please contact
['"comm...@mxnet.apache.org" '].


[GitHub] piiswrong closed pull request #9150: Install docs - update info about DLAMI

2017-12-27 Thread GitBox
piiswrong closed pull request #9150: Install docs - update info about DLAMI
URL: https://github.com/apache/incubator-mxnet/pull/9150
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/install/index.md b/docs/install/index.md
index c9ff073460..52dfaa84a4 100644
--- a/docs/install/index.md
+++ b/docs/install/index.md
@@ -704,11 +704,9 @@ More details and verified installation instructions for 
macOS, with GPUs, coming
 
 
 
-AWS Marketplace distributes AMIs (Amazon Machine Image) with MXNet 
pre-installed. You can launch an Amazon EC2 instance with one of the below AMIs:
-1. Deep Learning AMI (Amazon Machine Image) for 
[Ubuntu](https://aws.amazon.com/marketplace/pp/B06VSPXKDX)
-2. Deep Learning AMI for [Amazon 
Linux](https://aws.amazon.com/marketplace/pp/B01M0AXXQB)
+AWS Marketplace distributes Deep Learning AMIs (Amazon Machine Image) with 
MXNet pre-installed. You can launch one of these Deep Learning AMIs by 
following instructions in the [AWS Deep Learning AMI Developer 
Guide](http://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html).
 
-You could also run distributed deeplearning with *MXNet* on AWS using 
[Cloudformation 
Template](https://github.com/awslabs/deeplearning-cfn/blob/master/README.md).
+You can also run distributed deep learning with *MXNet* on AWS using 
[Cloudformation 
Template](https://github.com/awslabs/deeplearning-cfn/blob/master/README.md).
 
 
 


 


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


[GitHub] piiswrong closed pull request #9074: Rnn example updates

2017-12-27 Thread GitBox
piiswrong closed pull request #9074: Rnn example updates
URL: https://github.com/apache/incubator-mxnet/pull/9074
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/example/gluon/word_language_model/get_ptb_data.sh 
b/example/gluon/word_language_model/get_ptb_data.sh
index d2641cb32b..2dc4034a93 100755
--- a/example/gluon/word_language_model/get_ptb_data.sh
+++ b/example/gluon/word_language_model/get_ptb_data.sh
@@ -17,6 +17,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
+echo
+echo "NOTE: To continue, you need to review the licensing of the data sets 
used by this script"
+echo "See https://catalog.ldc.upenn.edu/ldc99t42 for the licensing"
+read -p "Please confirm you have reviewed the licensing [Y/n]:" -n 1 -r
+echo
+
+if [ $REPLY != "Y" ]
+then
+echo "License was not reviewed, aborting script."
+exit 1
+fi
 
 RNN_DIR=$(cd `dirname $0`; pwd)
 DATA_DIR="${RNN_DIR}/data/"
diff --git a/example/model-parallel/lstm/get_ptb_data.sh 
b/example/model-parallel/lstm/get_ptb_data.sh
index d2641cb32b..2dc4034a93 100755
--- a/example/model-parallel/lstm/get_ptb_data.sh
+++ b/example/model-parallel/lstm/get_ptb_data.sh
@@ -17,6 +17,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
+echo
+echo "NOTE: To continue, you need to review the licensing of the data sets 
used by this script"
+echo "See https://catalog.ldc.upenn.edu/ldc99t42 for the licensing"
+read -p "Please confirm you have reviewed the licensing [Y/n]:" -n 1 -r
+echo
+
+if [ $REPLY != "Y" ]
+then
+echo "License was not reviewed, aborting script."
+exit 1
+fi
 
 RNN_DIR=$(cd `dirname $0`; pwd)
 DATA_DIR="${RNN_DIR}/data/"
diff --git a/example/rnn-time-major/bucket_io.py 
b/example/rnn-time-major/bucket_io.py
index 950b0c05cf..e689ff1126 100644
--- a/example/rnn-time-major/bucket_io.py
+++ b/example/rnn-time-major/bucket_io.py
@@ -17,9 +17,8 @@
 
 # pylint: 
disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme
 # pylint: disable=superfluous-parens, no-member, invalid-name
+
 from __future__ import print_function
-import sys
-sys.path.insert(0, "../../python")
 import numpy as np
 import mxnet as mx
 
@@ -206,7 +205,7 @@ def make_data_iter_plan(self):
 bucket_n_batches.append(len(self.data[i]) / self.batch_size)
 self.data[i] = 
self.data[i][:int(bucket_n_batches[i]*self.batch_size)]
 
-bucket_plan = np.hstack([np.zeros(n, int)+i for i, n in 
enumerate(bucket_n_batches)])
+bucket_plan = np.hstack([np.zeros(int(n), int)+i for i, n in 
enumerate(bucket_n_batches)])
 np.random.shuffle(bucket_plan)
 
 bucket_idx_all = [np.random.permutation(len(x)) for x in self.data]
diff --git a/example/rnn-time-major/get_ptb_data.sh 
b/example/rnn-time-major/get_ptb_data.sh
index d2641cb32b..2dc4034a93 100755
--- a/example/rnn-time-major/get_ptb_data.sh
+++ b/example/rnn-time-major/get_ptb_data.sh
@@ -17,6 +17,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
+echo
+echo "NOTE: To continue, you need to review the licensing of the data sets 
used by this script"
+echo "See https://catalog.ldc.upenn.edu/ldc99t42 for the licensing"
+read -p "Please confirm you have reviewed the licensing [Y/n]:" -n 1 -r
+echo
+
+if [ $REPLY != "Y" ]
+then
+echo "License was not reviewed, aborting script."
+exit 1
+fi
 
 RNN_DIR=$(cd `dirname $0`; pwd)
 DATA_DIR="${RNN_DIR}/data/"
diff --git a/example/rnn-time-major/readme.md b/example/rnn-time-major/readme.md
new file mode 100644
index 00..7983fe8c6b
--- /dev/null
+++ b/example/rnn-time-major/readme.md
@@ -0,0 +1,24 @@
+Time major data layout for RNN
+==
+
+This example demonstrates an RNN implementation with Time-major layout. This 
implementation shows 1.5x-2x speedups compared to Batch-major RNN.
+   
+As example of Batch-major RNN is available in MXNet [RNN Bucketing 
example](https://github.com/apache/incubator-mxnet/tree/master/example/rnn/bucketing)
+   
+## Running the example
+- Prerequisite: an instance with GPU compute resources is required to run 
MXNet RNN
+- Make the shell script ```get_ptb_data.sh``` executable:
+```bash 
+chmod +x get_ptb_data.sh
+```
+- Run ```get_ptb_data.sh``` to download the PTB dataset, and follow the 
instructions to review the license:
+```bash
+./get_ptb_data.sh
+```
+The PTB data sets will be downloaded into ./data directory, and available 
for the example to train on.
+- Run the example:
+```bash
+python python rnn_cell_demo.py
+```
+
+If everything goes well, console will plot training speed and perplexity 
that you can compare to 

[incubator-mxnet] branch master updated: Rnn example updates (#9074)

2017-12-27 Thread jxie
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new 02b1131  Rnn example updates (#9074)
02b1131 is described below

commit 02b11313a2e2626ca95c4f5775dd98d15a74bd7a
Author: Hagay Lupesko 
AuthorDate: Wed Dec 27 11:48:27 2017 -0800

Rnn example updates (#9074)

* Get ptb script change for licensing issues (#8899)

* Print license notification before downloading dataset

* Print license notification before downloading dataset

* Fixing and improving rnn-time-major example

* Updating license review prompt to take input

* Updating PTB license review prompt to take input
---
 example/gluon/word_language_model/get_ptb_data.sh | 11 +
 example/model-parallel/lstm/get_ptb_data.sh   | 11 +
 example/rnn-time-major/bucket_io.py   |  5 ++--
 example/rnn-time-major/get_ptb_data.sh| 11 +
 example/rnn-time-major/readme.md  | 24 +++
 example/rnn-time-major/rnn_cell_demo.py   | 29 +++
 example/rnn/bucketing/get_ptb_data.sh | 11 +
 example/rnn/old/get_ptb_data.sh   | 11 +
 example/rnn/word_lm/get_ptb_data.sh   | 22 ++---
 perl-package/AI-MXNet/examples/get_ptb_data.sh| 11 +
 10 files changed, 131 insertions(+), 15 deletions(-)

diff --git a/example/gluon/word_language_model/get_ptb_data.sh 
b/example/gluon/word_language_model/get_ptb_data.sh
index d2641cb..2dc4034 100755
--- a/example/gluon/word_language_model/get_ptb_data.sh
+++ b/example/gluon/word_language_model/get_ptb_data.sh
@@ -17,6 +17,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
+echo
+echo "NOTE: To continue, you need to review the licensing of the data sets 
used by this script"
+echo "See https://catalog.ldc.upenn.edu/ldc99t42 for the licensing"
+read -p "Please confirm you have reviewed the licensing [Y/n]:" -n 1 -r
+echo
+
+if [ $REPLY != "Y" ]
+then
+echo "License was not reviewed, aborting script."
+exit 1
+fi
 
 RNN_DIR=$(cd `dirname $0`; pwd)
 DATA_DIR="${RNN_DIR}/data/"
diff --git a/example/model-parallel/lstm/get_ptb_data.sh 
b/example/model-parallel/lstm/get_ptb_data.sh
index d2641cb..2dc4034 100755
--- a/example/model-parallel/lstm/get_ptb_data.sh
+++ b/example/model-parallel/lstm/get_ptb_data.sh
@@ -17,6 +17,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
+echo
+echo "NOTE: To continue, you need to review the licensing of the data sets 
used by this script"
+echo "See https://catalog.ldc.upenn.edu/ldc99t42 for the licensing"
+read -p "Please confirm you have reviewed the licensing [Y/n]:" -n 1 -r
+echo
+
+if [ $REPLY != "Y" ]
+then
+echo "License was not reviewed, aborting script."
+exit 1
+fi
 
 RNN_DIR=$(cd `dirname $0`; pwd)
 DATA_DIR="${RNN_DIR}/data/"
diff --git a/example/rnn-time-major/bucket_io.py 
b/example/rnn-time-major/bucket_io.py
index 950b0c0..e689ff1 100644
--- a/example/rnn-time-major/bucket_io.py
+++ b/example/rnn-time-major/bucket_io.py
@@ -17,9 +17,8 @@
 
 # pylint: 
disable=C0111,too-many-arguments,too-many-instance-attributes,too-many-locals,redefined-outer-name,fixme
 # pylint: disable=superfluous-parens, no-member, invalid-name
+
 from __future__ import print_function
-import sys
-sys.path.insert(0, "../../python")
 import numpy as np
 import mxnet as mx
 
@@ -206,7 +205,7 @@ class BucketSentenceIter(mx.io.DataIter):
 bucket_n_batches.append(len(self.data[i]) / self.batch_size)
 self.data[i] = 
self.data[i][:int(bucket_n_batches[i]*self.batch_size)]
 
-bucket_plan = np.hstack([np.zeros(n, int)+i for i, n in 
enumerate(bucket_n_batches)])
+bucket_plan = np.hstack([np.zeros(int(n), int)+i for i, n in 
enumerate(bucket_n_batches)])
 np.random.shuffle(bucket_plan)
 
 bucket_idx_all = [np.random.permutation(len(x)) for x in self.data]
diff --git a/example/rnn-time-major/get_ptb_data.sh 
b/example/rnn-time-major/get_ptb_data.sh
index d2641cb..2dc4034 100755
--- a/example/rnn-time-major/get_ptb_data.sh
+++ b/example/rnn-time-major/get_ptb_data.sh
@@ -17,6 +17,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
+echo
+echo "NOTE: To continue, you need to review the licensing of the data sets 
used by this script"
+echo "See https://catalog.ldc.upenn.edu/ldc99t42 for the licensing"
+read -p "Please confirm you have reviewed the licensing [Y/n]:" -n 1 -r
+echo
+
+if [ $REPLY != "Y" ]
+then
+echo "License was not reviewed, aborting script."
+exit 1
+fi
 
 RNN_DIR=$(cd `dirname $0`; pwd)
 DATA_DIR="${RNN_DIR}/data/"
diff --git a/example/rnn-time-major/readme.md 

[GitHub] sxjscience commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
sxjscience commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158860112
 
 

 ##
 File path: tests/python/unittest/test_operator.py
 ##
 @@ -4315,21 +4315,24 @@ def check(data, idx):
 npdata = np.zeros_like(data.asnumpy())
 npdata[npidx] = y.asnumpy()
 assert (npdata == data.grad.asnumpy()).all()
-assert (mx.nd.scatter_nd(y, idx, shape=data.shape).asnumpy() == 
data.grad.asnumpy()).all()
-
-data = mx.nd.arange(360, dtype='int32').reshape((3,4,5,6))
-idx = mx.nd.array([[1,1,2], [3, 3, 0], [3,2,1]], dtype='int32')
-
-check(data, idx)
-
-idx = mx.nd.array([[1,1,2], [3,3,0], [3,2,1], [5,2,4]], dtype='int32')
-
-check(data, idx)
-
-data = mx.nd.array([2, 3, 0])
-idx = mx.nd.array([[1, 1, 0], [0, 1, 0]])
-
-assert (mx.nd.scatter_nd(data, idx, shape=(2, 2)).asnumpy() == [[0, 0], 
[2, 3]]).all()
+assert (mx.nd.scatter_nd_acc(y, idx, shape=data.shape).asnumpy() == 
data.grad.asnumpy()).all()
+for dtype in ['int32', 'int64', 'float16', 'float32', 'float64']:
+data = mx.nd.arange(360, dtype=dtype).reshape((3,4,5,6))
+idx = mx.nd.array([[1,1,2], [3, 3, 0], [3,2,1]], dtype='int32')
+check(data, idx)
+
+idx = mx.nd.array([[1,1,2], [3,3,0], [3,2,1], [5,2,4]], dtype='int32')
+
+check(data, idx)
+
+data = mx.nd.array([2, 3, 0], dtype=dtype)
+idx = mx.nd.array([[1, 1, 0], [0, 1, 0]], dtype='int32')
+assert (mx.nd.scatter_nd(data, idx, shape=(2, 2)).asnumpy() == [[0, 
0], [2, 3]]).all()
+if dtype == 'int64':
+data = mx.nd.array([2123162361283621, -31231236374787,
+-112372937128970, -1378278798172378], 
dtype=dtype)
+idx = mx.nd.array([[0, 0, 0, 0]], dtype='int32')
+assert (mx.nd.scatter_nd_acc(data, idx, shape=(1,)).asnumpy()[0] 
== data.asnumpy().sum())
 
 Review comment:
   @piiswrong I've added another test case for the signed int64 case.


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


[GitHub] piiswrong closed pull request #9180: fix parameter overwrite in _generate_symbol_function_code

2017-12-27 Thread GitBox
piiswrong closed pull request #9180: fix parameter overwrite in 
_generate_symbol_function_code
URL: https://github.com/apache/incubator-mxnet/pull/9180
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/mxnet/symbol/register.py b/python/mxnet/symbol/register.py
index cf279d1403..7b293f5fbe 100644
--- a/python/mxnet/symbol/register.py
+++ b/python/mxnet/symbol/register.py
@@ -143,14 +143,14 @@ def %s(%s):"""%(func_name, ', '.join(signature)))
 code.append("""
 kwargs.update(AttrScope.current.get(attr))
 sym_kwargs = dict()
-keys = []
-vals = []
-for k, v in kwargs.items():
-if isinstance(v, SymbolBase):
-sym_kwargs[k] = v
+_keys = []
+_vals = []
+for _k, _v in kwargs.items():
+if isinstance(_v, SymbolBase):
+sym_kwargs[_k] = _v
 else:
-keys.append(k)
-vals.append(v)""")
+_keys.append(_k)
+_vals.append(_v)""")
 # NDArray args
 for name in ndarg_names: # pylint: 
disable=redefined-argument-from-local
 code.append("""
@@ -162,18 +162,18 @@ def %s(%s):"""%(func_name, ', '.join(signature)))
 for name in kwarg_names: # pylint: 
disable=redefined-argument-from-local
 code.append("""
 if %s is not _Null:
-keys.append('%s')
-vals.append(%s)"""%(name, name, name))
+_keys.append('%s')
+_vals.append(%s)"""%(name, name, name))
 # dtype
 if dtype_name is not None:
 code.append("""
 if %s is not _Null:
-keys.append('%s')
-vals.append(np.dtype(%s).name)"""%(dtype_name, dtype_name, dtype_name))
+_keys.append('%s')
+_vals.append(np.dtype(%s).name)"""%(dtype_name, dtype_name, 
dtype_name))
 
 code.append("""
 name = NameManager.current.get(name, '%s')
-return _symbol_creator(%d, None, sym_kwargs, keys, vals, name)"""%(
+return _symbol_creator(%d, None, sym_kwargs, _keys, _vals, name)"""%(
 func_name.lower(), handle.value))
 
 if signature_only:


 


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


[incubator-mxnet] branch master updated: fix parameter overwrite in _generate_symbol_function_code (#9180)

2017-12-27 Thread jxie
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new 01a2a40  fix parameter overwrite in _generate_symbol_function_code 
(#9180)
01a2a40 is described below

commit 01a2a40d5b2cb3dd250f4e4033d896380e1354bd
Author: viking 
AuthorDate: Thu Dec 28 03:43:46 2017 +0800

fix parameter overwrite in _generate_symbol_function_code (#9180)

* fix parameter overwrite in _generate_symbol_function_code

* fix keys missing problem introduced by previous commit
---
 python/mxnet/symbol/register.py | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/python/mxnet/symbol/register.py b/python/mxnet/symbol/register.py
index cf279d1..7b293f5 100644
--- a/python/mxnet/symbol/register.py
+++ b/python/mxnet/symbol/register.py
@@ -143,14 +143,14 @@ def %s(%s):"""%(func_name, ', '.join(signature)))
 code.append("""
 kwargs.update(AttrScope.current.get(attr))
 sym_kwargs = dict()
-keys = []
-vals = []
-for k, v in kwargs.items():
-if isinstance(v, SymbolBase):
-sym_kwargs[k] = v
+_keys = []
+_vals = []
+for _k, _v in kwargs.items():
+if isinstance(_v, SymbolBase):
+sym_kwargs[_k] = _v
 else:
-keys.append(k)
-vals.append(v)""")
+_keys.append(_k)
+_vals.append(_v)""")
 # NDArray args
 for name in ndarg_names: # pylint: 
disable=redefined-argument-from-local
 code.append("""
@@ -162,18 +162,18 @@ def %s(%s):"""%(func_name, ', '.join(signature)))
 for name in kwarg_names: # pylint: 
disable=redefined-argument-from-local
 code.append("""
 if %s is not _Null:
-keys.append('%s')
-vals.append(%s)"""%(name, name, name))
+_keys.append('%s')
+_vals.append(%s)"""%(name, name, name))
 # dtype
 if dtype_name is not None:
 code.append("""
 if %s is not _Null:
-keys.append('%s')
-vals.append(np.dtype(%s).name)"""%(dtype_name, dtype_name, dtype_name))
+_keys.append('%s')
+_vals.append(np.dtype(%s).name)"""%(dtype_name, dtype_name, 
dtype_name))
 
 code.append("""
 name = NameManager.current.get(name, '%s')
-return _symbol_creator(%d, None, sym_kwargs, keys, vals, name)"""%(
+return _symbol_creator(%d, None, sym_kwargs, _keys, _vals, name)"""%(
 func_name.lower(), handle.value))
 
 if signature_only:

-- 
To stop receiving notification emails like this one, please contact
['"comm...@mxnet.apache.org" '].


[GitHub] dingran opened a new issue #9211: mx.io.NDArrayIter with scipy.sparse, last batch becomes dense and with no warning upfront

2017-12-27 Thread GitBox
dingran opened a new issue #9211: mx.io.NDArrayIter with scipy.sparse, last 
batch becomes dense and with no warning upfront
URL: https://github.com/apache/incubator-mxnet/issues/9211
 
 
   I noticed that mx.io.NDArrayIter accepts scipy sparse matrix but does not 
properly handle the last batch (it becomes dense) and did not output an 
error/warning upfront (like it would do with nd.sparse matrix, with a message 
"`NDArrayIter` only supports ``CSRNDArray`` with `last_batch_handle` set to 
`discard`.").
   
   Please see attached ipython notebook printout as an example.
   printout: 
[example.pdf](https://github.com/apache/incubator-mxnet/files/1589726/example.pdf)
   ipynb file: 
[example.zip](https://github.com/apache/incubator-mxnet/files/1589725/example.zip)
   
   
   Mixing dense with sparse is not too bad with imperative mode but throws off 
the computation in symbolic mode (i.e. hybridized blocks) and the error 
messages weren't very helpful.
   
![2017-12-27_14-40-20](https://user-images.githubusercontent.com/12864782/34391493-f8f59188-eb13-11e7-9865-d89dd1c4316b.jpg)
   
   
   **Suggest to let NDArrayIter have the same behavior for scipy.sparse and 
nd.sparse.**


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


[GitHub] piiswrong commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
piiswrong commented on a change in pull request #9119: fix random generator: do 
not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158859281
 
 

 ##
 File path: python/mxnet/test_utils.py
 ##
 @@ -34,6 +34,7 @@
 import numpy as np
 import numpy.testing as npt
 import numpy.random as rnd
+import scipy.stats as ss
 
 Review comment:
   see mx.nd.sparse


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


[GitHub] sxjscience commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
sxjscience commented on a change in pull request #9119: fix random generator: 
do not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158858704
 
 

 ##
 File path: python/mxnet/test_utils.py
 ##
 @@ -34,6 +34,7 @@
 import numpy as np
 import numpy.testing as npt
 import numpy.random as rnd
+import scipy.stats as ss
 
 Review comment:
   How should I revise this? Move it to be inside the functions?


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


[GitHub] sxjscience commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
sxjscience commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158858084
 
 

 ##
 File path: src/common/cuda_utils.h
 ##
 @@ -479,6 +479,11 @@ static inline __device__ void 
atomicAdd(mshadow::half::half_t *address,
   } while (assumed != old);
 }
 
+// Overload atomicAdd to work for signed int64 on all architectures
+static inline  __device__  void atomicAdd(int64_t *address, int64_t val) {
+  atomicAdd(reinterpret_cast(address), 
static_cast(val)); // NOLINT
 
 Review comment:
   It should be safe if CUDA uses 2's complement to implement the signed long 
long.


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


[GitHub] piiswrong commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
piiswrong commented on a change in pull request #9119: fix random generator: do 
not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158856581
 
 

 ##
 File path: src/operator/mxnet_op.h
 ##
 @@ -448,6 +449,47 @@ struct Kernel {
 #endif
   }
 
+  /*!
+   * \brief Launch a generic CPU kernel with native random generator.
+   * \tparam rnd CPU random generator
+   * \tparam Args Varargs type to eventually pass to the OP::Map() functoion
+   * \param N Number of iterations
+   * \param args Varargs to eventually pass to the OP::Map() functoion
+   */
+  template
+  inline static void LaunchRNG(mshadow::Stream *,
+   common::random::RandGenerator *rnd,
+   const int N, Args... args) {
+using namespace mxnet::common::random;
+#ifdef _OPENMP
+const int omp_threads = std::min(kCPURndStateNum,
+engine::OpenMP::Get()->GetRecommendedOMPThreadCount());
+if (omp_threads < 2) {
 
 Review comment:
   This was intentional.
   OpenMP disables some compiler optimizations, so an omp loop with 1 thread is 
slower than a simple loop without omp


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


[GitHub] piiswrong commented on a change in pull request #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
piiswrong commented on a change in pull request #9200: Fix the gradient of 
gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#discussion_r158855265
 
 

 ##
 File path: src/common/cuda_utils.h
 ##
 @@ -479,6 +479,11 @@ static inline __device__ void 
atomicAdd(mshadow::half::half_t *address,
   } while (assumed != old);
 }
 
+// Overload atomicAdd to work for signed int64 on all architectures
+static inline  __device__  void atomicAdd(int64_t *address, int64_t val) {
+  atomicAdd(reinterpret_cast(address), 
static_cast(val)); // NOLINT
 
 Review comment:
   are you sure this works for negative value?


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


[GitHub] piiswrong commented on issue #9200: Fix the gradient of gather_nd

2017-12-27 Thread GitBox
piiswrong commented on issue #9200: Fix the gradient of gather_nd
URL: https://github.com/apache/incubator-mxnet/pull/9200#issuecomment-354159686
 
 
   @reminisce 


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


[incubator-mxnet] branch master updated: Support negative axis in concat (#9204)

2017-12-27 Thread jxie
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new 911c81e  Support negative axis in concat (#9204)
911c81e is described below

commit 911c81ea7f0598235adea68a788fec429481c317
Author: Xingjian Shi 
AuthorDate: Wed Dec 27 10:55:18 2017 -0800

Support negative axis in concat (#9204)

* try to enable negative axis in concat

fix bug

update test

revise test

* initialize the variable

* revise test
---
 src/operator/concat-inl.h  | 39 +-
 tests/python/unittest/test_operator.py | 11 +-
 2 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/src/operator/concat-inl.h b/src/operator/concat-inl.h
index fdbe330..4225ddf 100644
--- a/src/operator/concat-inl.h
+++ b/src/operator/concat-inl.h
@@ -35,6 +35,7 @@
 #include 
 #include "./operator_common.h"
 #include "./channel_op_common.h"
+#include "./tensor/broadcast_reduce_op.h"
 
 namespace mxnet {
 namespace op {
@@ -50,7 +51,7 @@ struct ConcatParam : public dmlc::Parameter {
   DMLC_DECLARE_PARAMETER(ConcatParam) {
 DMLC_DECLARE_FIELD(num_args).set_lower_bound(1)
 .describe("Number of inputs to be concated.");
-DMLC_DECLARE_FIELD(dim).set_range(0,  4).set_default(1)
+DMLC_DECLARE_FIELD(dim).set_default(1)
 .describe("the dimension to be concated.");
   }
 };  // struct ConcatParam
@@ -70,23 +71,23 @@ class ConcatOp : public Operator {
 using namespace mshadow::expr;
 CHECK_EQ(static_cast(in_data.size()), size_);
 CHECK_EQ(out_data.size(), 1U);
-CHECK_LT(dimension_, in_data[concat_enum::kData0].ndim());
+int axis = CheckAxis(dimension_, in_data[concat_enum::kData0].ndim());
 Stream *s = ctx.get_stream();
 std::vector > data(size_);
 Tensor out;
 size_t leading = 1, trailing = 1;
-for (int i = 0; i < dimension_; ++i) {
+for (int i = 0; i < axis; ++i) {
   leading *= out_data[concat_enum::kOut].shape_[i];
 }
-for (int i = dimension_ + 1; i < out_data[concat_enum::kOut].ndim(); ++i) {
+for (int i = axis + 1; i < out_data[concat_enum::kOut].ndim(); ++i) {
   trailing *= out_data[concat_enum::kOut].shape_[i];
 }
-size_t mid = out_data[concat_enum::kOut].shape_[dimension_];
+size_t mid = out_data[concat_enum::kOut].shape_[axis];
 Shape<3> oshape = Shape3(leading, mid, trailing);
 out = out_data[concat_enum::kOut].get_with_shape(oshape, s);
 
 for (int i = 0; i < size_; ++i) {
-  Shape<3> dshape = Shape3(leading, in_data[i].shape_[dimension_], 
trailing);
+  Shape<3> dshape = Shape3(leading, in_data[i].shape_[axis], trailing);
   data[i] = in_data[i].get_with_shape(dshape, s);
 }
 Concatenate(data, , 1, req[concat_enum::kOut]);
@@ -103,22 +104,23 @@ class ConcatOp : public Operator {
 using namespace mshadow::expr;
 CHECK_EQ(out_grad.size(), 1U);
 CHECK_EQ(in_grad.size(), static_cast(size_));
+int axis = CheckAxis(dimension_, out_grad[concat_enum::kData0].ndim());
 Stream *s = ctx.get_stream();
 std::vector > grad_in(size_);
 Tensor grad;
 size_t leading = 1, trailing = 1;
-for (int i = 0; i < dimension_; ++i) {
+for (int i = 0; i < axis; ++i) {
   leading *= out_grad[concat_enum::kOut].shape_[i];
 }
-for (int i = dimension_ + 1; i < out_grad[concat_enum::kOut].ndim(); ++i) {
+for (int i = axis + 1; i < out_grad[concat_enum::kOut].ndim(); ++i) {
   trailing *= out_grad[concat_enum::kOut].shape_[i];
 }
-size_t mid = out_grad[concat_enum::kOut].shape_[dimension_];
+size_t mid = out_grad[concat_enum::kOut].shape_[axis];
 Shape<3> oshape = Shape3(leading, mid, trailing);
 grad = out_grad[concat_enum::kOut].get_with_shape(oshape, 
s);
 
 for (int i = 0; i < size_; ++i) {
-  Shape<3> dshape = Shape3(leading, in_grad[i].shape_[dimension_], 
trailing);
+  Shape<3> dshape = Shape3(leading, in_grad[i].shape_[axis], trailing);
   grad_in[i] = in_grad[i].get_with_shape(dshape, s);
 }
 Split(grad, _in, 1, req);
@@ -159,23 +161,22 @@ class ConcatProp : public OperatorProperty {
 TShape dshape;
 index_t size = 0;
 bool has_zero = false;
+int axis = -1;
 for (int i = 0; i < param_.num_args; ++i) {
   TShape tmp = (*in_shape)[i];
   if (tmp.ndim()) {
-CHECK_LT(static_cast(param_.dim), tmp.ndim())
-  << "concat dim " << param_.dim << " out of range of input shape " << 
tmp;
-has_zero = tmp[param_.dim] == 0 || has_zero;
-size += tmp[param_.dim];
-tmp[param_.dim] = 0;
+axis = CheckAxis(param_.dim, tmp.ndim());
+has_zero 

[GitHub] piiswrong closed pull request #9204: Support negative axis in concat

2017-12-27 Thread GitBox
piiswrong closed pull request #9204: Support negative axis in concat
URL: https://github.com/apache/incubator-mxnet/pull/9204
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/operator/concat-inl.h b/src/operator/concat-inl.h
index fdbe33072a..4225ddf4ea 100644
--- a/src/operator/concat-inl.h
+++ b/src/operator/concat-inl.h
@@ -35,6 +35,7 @@
 #include 
 #include "./operator_common.h"
 #include "./channel_op_common.h"
+#include "./tensor/broadcast_reduce_op.h"
 
 namespace mxnet {
 namespace op {
@@ -50,7 +51,7 @@ struct ConcatParam : public dmlc::Parameter {
   DMLC_DECLARE_PARAMETER(ConcatParam) {
 DMLC_DECLARE_FIELD(num_args).set_lower_bound(1)
 .describe("Number of inputs to be concated.");
-DMLC_DECLARE_FIELD(dim).set_range(0,  4).set_default(1)
+DMLC_DECLARE_FIELD(dim).set_default(1)
 .describe("the dimension to be concated.");
   }
 };  // struct ConcatParam
@@ -70,23 +71,23 @@ class ConcatOp : public Operator {
 using namespace mshadow::expr;
 CHECK_EQ(static_cast(in_data.size()), size_);
 CHECK_EQ(out_data.size(), 1U);
-CHECK_LT(dimension_, in_data[concat_enum::kData0].ndim());
+int axis = CheckAxis(dimension_, in_data[concat_enum::kData0].ndim());
 Stream *s = ctx.get_stream();
 std::vector > data(size_);
 Tensor out;
 size_t leading = 1, trailing = 1;
-for (int i = 0; i < dimension_; ++i) {
+for (int i = 0; i < axis; ++i) {
   leading *= out_data[concat_enum::kOut].shape_[i];
 }
-for (int i = dimension_ + 1; i < out_data[concat_enum::kOut].ndim(); ++i) {
+for (int i = axis + 1; i < out_data[concat_enum::kOut].ndim(); ++i) {
   trailing *= out_data[concat_enum::kOut].shape_[i];
 }
-size_t mid = out_data[concat_enum::kOut].shape_[dimension_];
+size_t mid = out_data[concat_enum::kOut].shape_[axis];
 Shape<3> oshape = Shape3(leading, mid, trailing);
 out = out_data[concat_enum::kOut].get_with_shape(oshape, s);
 
 for (int i = 0; i < size_; ++i) {
-  Shape<3> dshape = Shape3(leading, in_data[i].shape_[dimension_], 
trailing);
+  Shape<3> dshape = Shape3(leading, in_data[i].shape_[axis], trailing);
   data[i] = in_data[i].get_with_shape(dshape, s);
 }
 Concatenate(data, , 1, req[concat_enum::kOut]);
@@ -103,22 +104,23 @@ class ConcatOp : public Operator {
 using namespace mshadow::expr;
 CHECK_EQ(out_grad.size(), 1U);
 CHECK_EQ(in_grad.size(), static_cast(size_));
+int axis = CheckAxis(dimension_, out_grad[concat_enum::kData0].ndim());
 Stream *s = ctx.get_stream();
 std::vector > grad_in(size_);
 Tensor grad;
 size_t leading = 1, trailing = 1;
-for (int i = 0; i < dimension_; ++i) {
+for (int i = 0; i < axis; ++i) {
   leading *= out_grad[concat_enum::kOut].shape_[i];
 }
-for (int i = dimension_ + 1; i < out_grad[concat_enum::kOut].ndim(); ++i) {
+for (int i = axis + 1; i < out_grad[concat_enum::kOut].ndim(); ++i) {
   trailing *= out_grad[concat_enum::kOut].shape_[i];
 }
-size_t mid = out_grad[concat_enum::kOut].shape_[dimension_];
+size_t mid = out_grad[concat_enum::kOut].shape_[axis];
 Shape<3> oshape = Shape3(leading, mid, trailing);
 grad = out_grad[concat_enum::kOut].get_with_shape(oshape, 
s);
 
 for (int i = 0; i < size_; ++i) {
-  Shape<3> dshape = Shape3(leading, in_grad[i].shape_[dimension_], 
trailing);
+  Shape<3> dshape = Shape3(leading, in_grad[i].shape_[axis], trailing);
   grad_in[i] = in_grad[i].get_with_shape(dshape, s);
 }
 Split(grad, _in, 1, req);
@@ -159,23 +161,22 @@ class ConcatProp : public OperatorProperty {
 TShape dshape;
 index_t size = 0;
 bool has_zero = false;
+int axis = -1;
 for (int i = 0; i < param_.num_args; ++i) {
   TShape tmp = (*in_shape)[i];
   if (tmp.ndim()) {
-CHECK_LT(static_cast(param_.dim), tmp.ndim())
-  << "concat dim " << param_.dim << " out of range of input shape " << 
tmp;
-has_zero = tmp[param_.dim] == 0 || has_zero;
-size += tmp[param_.dim];
-tmp[param_.dim] = 0;
+axis = CheckAxis(param_.dim, tmp.ndim());
+has_zero = tmp[axis] == 0 || has_zero;
+size += tmp[axis];
+tmp[axis] = 0;
 shape_assign(, tmp);
   }
 }
 
 TShape tmp = (*out_shape)[0];
 if (tmp.ndim()) {
-  CHECK_LT(static_cast(param_.dim), tmp.ndim())
-<< "concat dim " << param_.dim << " out of range of input shape " << 
tmp;
-  tmp[param_.dim] = 0;
+  axis = CheckAxis(param_.dim, tmp.ndim());
+  tmp[axis] = 0;
   shape_assign(, tmp);
 

[GitHub] piiswrong closed pull request #9206: Fix incude error in plugin/opencv/cv_api.cc

2017-12-27 Thread GitBox
piiswrong closed pull request #9206: Fix incude error in plugin/opencv/cv_api.cc
URL: https://github.com/apache/incubator-mxnet/pull/9206
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/plugin/opencv/cv_api.cc b/plugin/opencv/cv_api.cc
index 1ca14aa460..53eb8524c7 100644
--- a/plugin/opencv/cv_api.cc
+++ b/plugin/opencv/cv_api.cc
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include "cv_api.h"
-#include "../../src/c_api/c_api_error.h"
+#include "../../src/c_api/c_api_common.h"
 
 
 using namespace mxnet;


 


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


[incubator-mxnet] branch master updated: fix incude error in plugin/opencv/cv_api.cc (#9206)

2017-12-27 Thread jxie
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new ad1ed7c  fix incude error in plugin/opencv/cv_api.cc (#9206)
ad1ed7c is described below

commit ad1ed7c9806eb47cf3042105715b517eb4ed7f40
Author: MinWoo Byeon 
AuthorDate: Thu Dec 28 03:48:37 2017 +0900

fix incude error in plugin/opencv/cv_api.cc (#9206)
---
 plugin/opencv/cv_api.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugin/opencv/cv_api.cc b/plugin/opencv/cv_api.cc
index 1ca14aa..53eb852 100644
--- a/plugin/opencv/cv_api.cc
+++ b/plugin/opencv/cv_api.cc
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include "cv_api.h"
-#include "../../src/c_api/c_api_error.h"
+#include "../../src/c_api/c_api_common.h"
 
 
 using namespace mxnet;

-- 
To stop receiving notification emails like this one, please contact
['"comm...@mxnet.apache.org" '].


[GitHub] meetshah1995 commented on issue #3664: ubuntu 16.04 compile errror

2017-12-27 Thread GitBox
meetshah1995 commented on issue #3664: ubuntu 16.04 compile errror
URL: 
https://github.com/apache/incubator-mxnet/issues/3664#issuecomment-354155867
 
 
   Any Solutions to this?


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


[GitHub] szha commented on issue #6915: Training Faster R-CNN on own dataset

2017-12-27 Thread GitBox
szha commented on issue #6915: Training Faster R-CNN on own dataset
URL: 
https://github.com/apache/incubator-mxnet/issues/6915#issuecomment-354106788
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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


[GitHub] szha commented on issue #8039: MXPredCreate() costs all my memory(24G), and shows "terminate called after throwing an instance of 'std::bad_alloc"

2017-12-27 Thread GitBox
szha commented on issue #8039: MXPredCreate() costs all my memory(24G), and 
shows "terminate called after throwing an instance of 'std::bad_alloc"
URL: 
https://github.com/apache/incubator-mxnet/issues/8039#issuecomment-354106786
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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


[GitHub] szha commented on issue #7847: Bug on Multi GPU : probably Invalid initialization of optimizer

2017-12-27 Thread GitBox
szha commented on issue #7847: Bug on Multi GPU : probably Invalid 
initialization of optimizer
URL: 
https://github.com/apache/incubator-mxnet/issues/7847#issuecomment-354106789
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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


[GitHub] szha commented on issue #8023: Error in continuing training a model loaded from file

2017-12-27 Thread GitBox
szha commented on issue #8023: Error in continuing training a model loaded from 
file
URL: 
https://github.com/apache/incubator-mxnet/issues/8023#issuecomment-354106784
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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


[GitHub] szha commented on issue #8037: How to maximize one loss function and minimize another one?

2017-12-27 Thread GitBox
szha commented on issue #8037: How to maximize one loss function and minimize 
another one?
URL: 
https://github.com/apache/incubator-mxnet/issues/8037#issuecomment-354106792
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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


[GitHub] zihaolucky commented on a change in pull request #9195: [WIP]NCE loss gluon

2017-12-27 Thread GitBox
zihaolucky commented on a change in pull request #9195: [WIP]NCE loss gluon
URL: https://github.com/apache/incubator-mxnet/pull/9195#discussion_r158801163
 
 

 ##
 File path: example/gluon/sampler/alias_method.py
 ##
 @@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# coding: utf-8
+# pylint: skip-file
+
+import numpy as np
+import numpy.random as npr
+from collections import Counter
+
+import mxnet.gluon as gluon
+
+K = 5
+N = 1000
+
+# Get a random probability vector.
+probs = npr.dirichlet(np.ones(K), 1).ravel()
+
+# Construct the table.
+alias_method_sampler = gluon.data.AliasMethodSampler(K, probs)
+
+# Generate variates.
+X = alias_method_sampler.draw(N).asnumpy()
+c = Counter(X)
+
+# check sampled probabilities
+sampled_probs = [float(x)/N for x in c.values()]
 
 Review comment:
   @sxjscience Good idea.


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


[GitHub] zihaolucky commented on a change in pull request #9195: [WIP]NCE loss gluon

2017-12-27 Thread GitBox
zihaolucky commented on a change in pull request #9195: [WIP]NCE loss gluon
URL: https://github.com/apache/incubator-mxnet/pull/9195#discussion_r158791226
 
 

 ##
 File path: python/mxnet/gluon/data/sampler.py
 ##
 @@ -136,3 +138,74 @@ def __len__(self):
 raise ValueError(
 "last_batch must be one of 'keep', 'discard', or 'rollover', " \
 "but got %s"%self._last_batch)
+
+
+class AliasMethodSampler(object):
+""" The Alias Method: Efficient Sampling with Many Discrete Outcomes.
+Can be use in NCELoss.
+
+Parameters
+--
+K : int
+Number of events.
+probs : array
+Probability of each events, corresponds to K.
+
+References
+---
+
https://hips.seas.harvard.edu/blog/2013/03/03/the-alias-method-efficient-sampling-with-many-discrete-outcomes/
+"""
+def __init__(self, K, probs):
+if K != len(probs):
+raise ValueError("K should be equal to len(probs). K:%d, 
len(probs):%d" % (K, len(probs)))
+self.K = K
+self.prob = nd.zeros(K)
+self.alias = nd.zeros(K, dtype='int32')
+
+# Sort the data into the outcomes with probabilities
+# that are larger and smaller than 1/K.
+smaller = []
+larger = []
+for kk, prob in enumerate(probs):
+self.prob[kk] = K*prob
+if self.prob[kk] < 1.0:
 
 Review comment:
   I would compare the speed later and report here.


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


[GitHub] zihaolucky commented on a change in pull request #9195: [WIP]NCE loss gluon

2017-12-27 Thread GitBox
zihaolucky commented on a change in pull request #9195: [WIP]NCE loss gluon
URL: https://github.com/apache/incubator-mxnet/pull/9195#discussion_r158790932
 
 

 ##
 File path: python/mxnet/gluon/data/sampler.py
 ##
 @@ -136,3 +138,74 @@ def __len__(self):
 raise ValueError(
 "last_batch must be one of 'keep', 'discard', or 'rollover', " \
 "but got %s"%self._last_batch)
+
+
+class AliasMethodSampler(object):
+""" The Alias Method: Efficient Sampling with Many Discrete Outcomes.
+Can be use in NCELoss.
+
+Parameters
+--
+K : int
+Number of events.
+probs : array
+Probability of each events, corresponds to K.
+
+References
+---
+
https://hips.seas.harvard.edu/blog/2013/03/03/the-alias-method-efficient-sampling-with-many-discrete-outcomes/
+"""
+def __init__(self, K, probs):
+if K != len(probs):
+raise ValueError("K should be equal to len(probs). K:%d, 
len(probs):%d" % (K, len(probs)))
+self.K = K
+self.prob = nd.zeros(K)
+self.alias = nd.zeros(K, dtype='int32')
+
+# Sort the data into the outcomes with probabilities
+# that are larger and smaller than 1/K.
+smaller = []
+larger = []
+for kk, prob in enumerate(probs):
+self.prob[kk] = K*prob
+if self.prob[kk] < 1.0:
 
 Review comment:
   #9209 FYI, a relevant issue here.


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


[GitHub] edmBernard commented on issue #9209: Speed between Ndarry and Numpy

2017-12-27 Thread GitBox
edmBernard commented on issue #9209: Speed between Ndarry and Numpy
URL: 
https://github.com/apache/incubator-mxnet/issues/9209#issuecomment-354087204
 
 
   on my pc with your script I got 
   8s for nd.array on cpu and 15s for np array on cpu:
   ```python
   import numpy as np
   import mxnet as mx
   import time
   
   def argmax_nd():
   gpu_device = mx.cpu(0)
   t = time.time()
   for i in xrange(100):
   with mx.Context(gpu_device):
   nd_a = mx.nd.array(np.random.randint(10, size=(176, 176, 100)))
   nd_a -= mx.nd.min(nd_a, axis=(0, 1))
   nd_a /= (mx.nd.sum(nd_a, axis=(0, 1)) + 1e-8)
   b = 0.38 * nd_a + mx.nd.ones(nd_a.shape) * (1 - 0.38)
   c = b.reshape((-1, nd_a.shape[2]))
   d = mx.nd.argmax(c, axis=0)
   y = d / 176 - 176/2.
   x = d % 176 - 176/2.
   m = x.asnumpy()
   n = y.asnumpy()
   print 'argmax time: ', time.time() - t
   
   def argmax_np():
   t = time.time()
   for i in xrange(100):
   np_a = np.random.randint(10, size=(176, 176, 100)).astype(float)
   np_a -= np.min(np_a, axis=(0, 1))
   np_a /= (np.sum(np_a, axis=(0, 1)) + 1e-8)
   b = 0.38 * np_a + np.ones(np_a.shape) * (1 - 0.38)
   c = b.reshape((-1, np_a.shape[2]))
   d = np.argmax(c, axis=0)
   y = d / 176 - 176/2.
   x = d % 176 - 176/2.
   print 'argmax time: ', time.time() - t
   
   
   argmax_np()
   argmax_nd()
   ```


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


[GitHub] fcbruce commented on issue #9207: It seems nd.array or NDArrayIter not support too large array

2017-12-27 Thread GitBox
fcbruce commented on issue #9207: It seems nd.array or NDArrayIter not support 
too large array
URL: 
https://github.com/apache/incubator-mxnet/issues/9207#issuecomment-354077264
 
 
   @mwbyeon Sorry, It's my fault, lost a zero
   ```
   import numpy as np
   import mxnet as mx
   X = np.zeros((20, 32768), dtypes=np.float32)
   mx.nd.array(X)
   ```
   My MacOS has 8GB and CentOS has 64GB


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


[GitHub] TX2012LH opened a new issue #9209: Speed between Ndarry and Numpy

2017-12-27 Thread GitBox
TX2012LH opened a new issue #9209: Speed between Ndarry and Numpy
URL: https://github.com/apache/incubator-mxnet/issues/9209
 
 
   ## Description
   I write one demo to compare speed between Ndarray and Numpy and I find that 
cpu-Ndarray is not as fast as Numpy?
   
   ## Environment info
   ubunut 14.04
   gpu titan x
   
   ## Code
   ``` python
   def argmax_nd():
   gpu_device = mx.gpu()
   for i in xrange(100):
   with mx.Context(gpu_device):
   nd_a = mx.nd.array(np.random.randint(10, size=(176, 176, 100)))
   t = time.time()
   nd_a -= mx.nd.min(nd_a, axis=(0, 1))
   nd_a /= (mx.nd.sum(nd_a, axis=(0, 1)) + 1e-8)
   b = 0.38 * nd_a + mx.nd.ones(nd_a.shape) * (1 - 0.38)
   c = b.reshape((-1, nd_a.shape[2]))
   d = mx.nd.argmax(c, axis=0)
   y = d / 176 - 176/2.
   x = d % 176 - 176/2.
   m = x.asnumpy()
   n = y.asnumpy()
   print 'argmax time: ', time.time() - t
   
   def argmax_np():
   for i in xrange(100):
   np_a = np.random.randint(10, size=(176, 176, 100)).astype(float)
   t = time.time()
   np_a -= np.min(np_a, axis=(0, 1))
   np_a /= (np.sum(np_a, axis=(0, 1)) + 1e-8)
   b = 0.38 * np_a + np.ones(np_a.shape) * (1 - 0.38)
   c = b.reshape((-1, np_a.shape[2]))
   d = np.argmax(c, axis=0)
   y = d / 176 - 176/2.
   x = d % 176 - 176/2.
   print 'argmax time: ', time.time() - t
   ```
   ## Time Cost
   GPU-Ndarray: 23ms
   CPU-Ndarray: 82ms
   Numpy: 45 ms


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


[GitHub] cloudhan commented on issue #8951: Not all latest version has prebuild binary for Windows on PyPI

2017-12-27 Thread GitBox
cloudhan commented on issue #8951: Not all latest version has prebuild binary 
for Windows on PyPI
URL: 
https://github.com/apache/incubator-mxnet/issues/8951#issuecomment-354075049
 
 
   @whatever1983 CUDA 9.1 have released, so you should expect more ;)


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


[GitHub] mwbyeon commented on issue #9207: It seems nd.array or NDArrayIter not support too large array

2017-12-27 Thread GitBox
mwbyeon commented on issue #9207: It seems nd.array or NDArrayIter not support 
too large array
URL: 
https://github.com/apache/incubator-mxnet/issues/9207#issuecomment-354074516
 
 
   @fcbruce 
   
   It works.
   ```
   $ pip install mxnet
   $ python
   Python 3.6.3 (default, Oct 19 2017, 23:50:38)
   [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.38)] on darwin
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import mxnet as mx
   >>> mx.__version__
   '1.0.0'
   >>> import numpy as np
   >>> X = np.zeros((2, 32768), dtype=np.float32)
   >>> mx.nd.array(X)
   
   [[ 0.  0.  0. ...,  0.  0.  0.]
[ 0.  0.  0. ...,  0.  0.  0.]
[ 0.  0.  0. ...,  0.  0.  0.]
...,
[ 0.  0.  0. ...,  0.  0.  0.]
[ 0.  0.  0. ...,  0.  0.  0.]
[ 0.  0.  0. ...,  0.  0.  0.]]
   
   >>>
   ```
   
   what's your memory capacity?
   your array is required 2.4GB memory (2*32768*4bytes).
   (I tested on MacOS with 16GB Memory)
   
   if exceed memory capacity, it occurs above error message. 
   
   ```
   >>> mx.nd.array(np.zeros((20, 32768), dtype=np.float32))
   [17:23:34] 
/Users/travis/build/dmlc/mxnet-distro/mxnet-build/dmlc-core/include/dmlc/logging.h:308:
 [17:23:34] include/mxnet/./tensor_blob.h:276: Check failed: 
this->shape_.Size() == shape.Size() (655360 vs. 2258632704) 
TBlob.get_with_shape: new and old shape do not match total elements
   
   Stack trace returned 7 entries:
   [bt] (0) 0   libmxnet.so 0x000107116b98 
_ZN4dmlc15LogMessageFatalD2Ev + 40
   [bt] (1) 1   libmxnet.so 0x00010713b7c9 
_ZNK5mxnet5TBlob14get_with_shapeIN7mshadow3cpuELi1EfEENS2_6TensorIT_XT0_ET1_EERKNS2_5ShapeIXT0_EEEPNS2_6StreamIS5_EE
 + 777
   [bt] (2) 2   libmxnet.so 0x00010819427e 
_ZN5mxnet7ndarray4CopyIN7mshadow3cpuES3_EEvRKNS_5TBlobEPS4_NS_7ContextES8_NS_10RunContextE
 + 14382
   [bt] (3) 3   libmxnet.so 0x00010816e1e5 
_ZNK5mxnet7NDArray15SyncCopyFromCPUEPKvm + 1109
   [bt] (4) 4   libmxnet.so 0x000107ffb2cd 
MXNDArraySyncCopyFromCPU + 13
   [bt] (5) 5   _ctypes.cpython-36m-darwin.so   0x00010628d02f 
ffi_call_unix64 + 79
   [bt] (6) 6   ??? 0x7ffeea4422a0 0x0 + 
140732828754592
   
   Traceback (most recent call last):
 File "", line 1, in 
 File 
"/Users/dylan/.pyenv/versions/mxnet/lib/python3.6/site-packages/mxnet/ndarray/utils.py",
 line 146, in array
   return _array(source_array, ctx=ctx, dtype=dtype)
 File 
"/Users/dylan/.pyenv/versions/mxnet/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py",
 line 2245, in array
   arr[:] = source_array
 File 
"/Users/dylan/.pyenv/versions/mxnet/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py",
 line 437, in __setitem__
   self._set_nd_basic_indexing(key, value)
 File 
"/Users/dylan/.pyenv/versions/mxnet/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py",
 line 698, in _set_nd_basic_indexing
   self._sync_copyfrom(value)
 File 
"/Users/dylan/.pyenv/versions/mxnet/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py",
 line 863, in _sync_copyfrom
   ctypes.c_size_t(source_array.size)))
 File 
"/Users/dylan/.pyenv/versions/mxnet/lib/python3.6/site-packages/mxnet/base.py", 
line 146, in check_call
   raise MXNetError(py_str(_LIB.MXGetLastError()))
   mxnet.base.MXNetError: [17:23:34] include/mxnet/./tensor_blob.h:276: Check 
failed: this->shape_.Size() == shape.Size() (655360 vs. 2258632704) 
TBlob.get_with_shape: new and old shape do not match total elements
   
   Stack trace returned 7 entries:
   [bt] (0) 0   libmxnet.so 0x000107116b98 
_ZN4dmlc15LogMessageFatalD2Ev + 40
   [bt] (1) 1   libmxnet.so 0x00010713b7c9 
_ZNK5mxnet5TBlob14get_with_shapeIN7mshadow3cpuELi1EfEENS2_6TensorIT_XT0_ET1_EERKNS2_5ShapeIXT0_EEEPNS2_6StreamIS5_EE
 + 777
   [bt] (2) 2   libmxnet.so 0x00010819427e 
_ZN5mxnet7ndarray4CopyIN7mshadow3cpuES3_EEvRKNS_5TBlobEPS4_NS_7ContextES8_NS_10RunContextE
 + 14382
   [bt] (3) 3   libmxnet.so 0x00010816e1e5 
_ZNK5mxnet7NDArray15SyncCopyFromCPUEPKvm + 1109
   [bt] (4) 4   libmxnet.so 0x000107ffb2cd 
MXNDArraySyncCopyFromCPU + 13
   [bt] (5) 5   _ctypes.cpython-36m-darwin.so   0x00010628d02f 
ffi_call_unix64 + 79
   [bt] (6) 6   ??? 0x7ffeea4422a0 0x0 + 
140732828754592
   
   >>>
   ```


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


[GitHub] javelinjs commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
javelinjs commented on a change in pull request #9119: fix random generator: do 
not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158777271
 
 

 ##
 File path: src/common/random_generator.h
 ##
 @@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * Copyright (c) 2017 by Contributors
+ * \file random_generator.h
+ * \brief Native random number generator.
+ */
+#ifndef MXNET_COMMON_RANDOM_GENERATOR_H_
+#define MXNET_COMMON_RANDOM_GENERATOR_H_
+
+#include 
+#include 
+#include 
+
+#if MXNET_USE_CUDA
+#include 
+#include 
+#include 
+#endif  // MXNET_USE_CUDA
+
+using namespace mshadow;
+
+namespace mxnet {
+namespace common {
+namespace random {
+
+template
+class RandGenerator;
+
+// Elementary random number generation for int/uniform/gaussian in CPU and GPU.
+// Will use float data type whenever instantiated for half_t or any other non
+// standard real type.
+template
+class RandGeneratorImpl;
+
+// at least how many random numbers should be generated by one CPU thread.
+const int kCPUMinRndNumberPerThread = 64;
+// store how many global random states for CPU.
+const int kCPURndStateNum = 1024;
+
+template
+class RandGeneratorImpl {
+ public:
+  typedef typename std::conditional::type FType;
+
+  explicit RandGeneratorImpl(std::mt19937 *ptr_engine) : 
engine_(ptr_engine) {}
+
+  MSHADOW_XINLINE int rand() { return engine_->operator()(); }
+
+  MSHADOW_XINLINE FType uniform() {
+typedef typename std::conditional::type GType;
+GType dist_uniform;
+return dist_uniform(*engine_);
+  }
+
+  MSHADOW_XINLINE FType normal() {
+std::normal_distribution dist_normal;
+return dist_normal(*engine_);
+  }
+
+ private:
+  std::mt19937 *engine_;
+};
+
+template
+class RandGenerator {
+ public:
+  MSHADOW_XINLINE void dispose() {}
+
+  MSHADOW_XINLINE RandGeneratorImpl Get(int idx = 0) {
+std::mt19937 *ptr_engine = _[idx];
+RandGeneratorImpl gen(ptr_engine);
+return gen;
+  }
+
+  MSHADOW_XINLINE void Seed(Stream *, uint32_t seed) {
+for (int i = 0; i < kCPURndStateNum; ++i) (states_ + i)->seed(seed + i);
+  }
+
+  MSHADOW_XINLINE void set_state(int idx, const std::mt19937 ) {
+states_[idx] = state;
+  }
+
+ private:
+  std::mt19937 states_[kCPURndStateNum];
+};
+
+#if MXNET_USE_CUDA
+
+// at least how many random numbers should be generated by one GPU thread.
+const int kGPUMinRndNumberPerThread = 64;
+// store how many global random states for GPU.
+const int kGPURndStateNum = 32768;
+
+// uniform number generation in Cuda made consistent with stl (include 0 but 
exclude 1)
+// by using 1.0-curand_uniform().
+// Needed as some samplers in sampler.h won't be able to deal with
+// one of the boundary cases.
+template
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
+
+  MSHADOW_FORCE_INLINE __device__ int rand() {
+return curand(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float uniform() {
+return static_cast(1.0) - curand_uniform(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float normal() {
+return curand_normal(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ curandStatePhilox4_32_10_t get_state() {
+return state_;
+  }
+
+ private:
+  curandStatePhilox4_32_10_t state_;
+};
+
+template<>
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
 
 Review comment:
   The implement here was correct. It did save the state back in `LaunchRNG`.
   I now refactor it to a more readable version.


This is an automated message from the Apache Git Service.
To respond to the 

[GitHub] cloudhan opened a new issue #9208: ndarray load and save should be device agnostic

2017-12-27 Thread GitBox
cloudhan opened a new issue #9208: ndarray load and save should be device 
agnostic
URL: https://github.com/apache/incubator-mxnet/issues/9208
 
 
   I have a set of saved parameter files with `mx.nd.save(...)`, the problem is 
that they are on gpu 7 before saving and I copy them to another machine with 
only 2 GPUs. When I try to load them I encounter the problem:
   ```
   Check failed: e == cudaSuccess CUDA: invalid device ordinal
   ``` 
   I know I can copy them to whatever device before saving. But what if the 
user loss access to those devices after dumping the ndarray to a file? 
   
   So I think the better default saving and loading mechanism should as 
following:
   
   `mx.nd.save(fname, data)` should be `mx.nd.save(fname, data, 
keep_ctx=False)` 
   that is, it save the parameter with cpu device by default, the user can 
override this default behavior, and they are on their own.
   
   and 
   
   `mx.nd.load(fname)`  should be `mx.nd.load(fname, as_in_ctx=None)` 
   `as_in_ctx` is a parameter of device or list of devices, this way, the 
loaded ndarray will be ready for binding (I am still using the old api) after 
this single invocation.
   
   


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


[GitHub] javelinjs commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
javelinjs commented on a change in pull request #9119: fix random generator: do 
not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158777271
 
 

 ##
 File path: src/common/random_generator.h
 ##
 @@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * Copyright (c) 2017 by Contributors
+ * \file random_generator.h
+ * \brief Native random number generator.
+ */
+#ifndef MXNET_COMMON_RANDOM_GENERATOR_H_
+#define MXNET_COMMON_RANDOM_GENERATOR_H_
+
+#include 
+#include 
+#include 
+
+#if MXNET_USE_CUDA
+#include 
+#include 
+#include 
+#endif  // MXNET_USE_CUDA
+
+using namespace mshadow;
+
+namespace mxnet {
+namespace common {
+namespace random {
+
+template
+class RandGenerator;
+
+// Elementary random number generation for int/uniform/gaussian in CPU and GPU.
+// Will use float data type whenever instantiated for half_t or any other non
+// standard real type.
+template
+class RandGeneratorImpl;
+
+// at least how many random numbers should be generated by one CPU thread.
+const int kCPUMinRndNumberPerThread = 64;
+// store how many global random states for CPU.
+const int kCPURndStateNum = 1024;
+
+template
+class RandGeneratorImpl {
+ public:
+  typedef typename std::conditional::type FType;
+
+  explicit RandGeneratorImpl(std::mt19937 *ptr_engine) : 
engine_(ptr_engine) {}
+
+  MSHADOW_XINLINE int rand() { return engine_->operator()(); }
+
+  MSHADOW_XINLINE FType uniform() {
+typedef typename std::conditional::type GType;
+GType dist_uniform;
+return dist_uniform(*engine_);
+  }
+
+  MSHADOW_XINLINE FType normal() {
+std::normal_distribution dist_normal;
+return dist_normal(*engine_);
+  }
+
+ private:
+  std::mt19937 *engine_;
+};
+
+template
+class RandGenerator {
+ public:
+  MSHADOW_XINLINE void dispose() {}
+
+  MSHADOW_XINLINE RandGeneratorImpl Get(int idx = 0) {
+std::mt19937 *ptr_engine = _[idx];
+RandGeneratorImpl gen(ptr_engine);
+return gen;
+  }
+
+  MSHADOW_XINLINE void Seed(Stream *, uint32_t seed) {
+for (int i = 0; i < kCPURndStateNum; ++i) (states_ + i)->seed(seed + i);
+  }
+
+  MSHADOW_XINLINE void set_state(int idx, const std::mt19937 ) {
+states_[idx] = state;
+  }
+
+ private:
+  std::mt19937 states_[kCPURndStateNum];
+};
+
+#if MXNET_USE_CUDA
+
+// at least how many random numbers should be generated by one GPU thread.
+const int kGPUMinRndNumberPerThread = 64;
+// store how many global random states for GPU.
+const int kGPURndStateNum = 32768;
+
+// uniform number generation in Cuda made consistent with stl (include 0 but 
exclude 1)
+// by using 1.0-curand_uniform().
+// Needed as some samplers in sampler.h won't be able to deal with
+// one of the boundary cases.
+template
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
+
+  MSHADOW_FORCE_INLINE __device__ int rand() {
+return curand(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float uniform() {
+return static_cast(1.0) - curand_uniform(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float normal() {
+return curand_normal(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ curandStatePhilox4_32_10_t get_state() {
+return state_;
+  }
+
+ private:
+  curandStatePhilox4_32_10_t state_;
+};
+
+template<>
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
 
 Review comment:
   The implement here was correct. It did save the state back in `LaunchRNG`.
   I refactor it to a more readable version.


This is an automated message from the Apache Git Service.
To respond to the 

[GitHub] javelinjs commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
javelinjs commented on a change in pull request #9119: fix random generator: do 
not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158777271
 
 

 ##
 File path: src/common/random_generator.h
 ##
 @@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * Copyright (c) 2017 by Contributors
+ * \file random_generator.h
+ * \brief Native random number generator.
+ */
+#ifndef MXNET_COMMON_RANDOM_GENERATOR_H_
+#define MXNET_COMMON_RANDOM_GENERATOR_H_
+
+#include 
+#include 
+#include 
+
+#if MXNET_USE_CUDA
+#include 
+#include 
+#include 
+#endif  // MXNET_USE_CUDA
+
+using namespace mshadow;
+
+namespace mxnet {
+namespace common {
+namespace random {
+
+template
+class RandGenerator;
+
+// Elementary random number generation for int/uniform/gaussian in CPU and GPU.
+// Will use float data type whenever instantiated for half_t or any other non
+// standard real type.
+template
+class RandGeneratorImpl;
+
+// at least how many random numbers should be generated by one CPU thread.
+const int kCPUMinRndNumberPerThread = 64;
+// store how many global random states for CPU.
+const int kCPURndStateNum = 1024;
+
+template
+class RandGeneratorImpl {
+ public:
+  typedef typename std::conditional::type FType;
+
+  explicit RandGeneratorImpl(std::mt19937 *ptr_engine) : 
engine_(ptr_engine) {}
+
+  MSHADOW_XINLINE int rand() { return engine_->operator()(); }
+
+  MSHADOW_XINLINE FType uniform() {
+typedef typename std::conditional::type GType;
+GType dist_uniform;
+return dist_uniform(*engine_);
+  }
+
+  MSHADOW_XINLINE FType normal() {
+std::normal_distribution dist_normal;
+return dist_normal(*engine_);
+  }
+
+ private:
+  std::mt19937 *engine_;
+};
+
+template
+class RandGenerator {
+ public:
+  MSHADOW_XINLINE void dispose() {}
+
+  MSHADOW_XINLINE RandGeneratorImpl Get(int idx = 0) {
+std::mt19937 *ptr_engine = _[idx];
+RandGeneratorImpl gen(ptr_engine);
+return gen;
+  }
+
+  MSHADOW_XINLINE void Seed(Stream *, uint32_t seed) {
+for (int i = 0; i < kCPURndStateNum; ++i) (states_ + i)->seed(seed + i);
+  }
+
+  MSHADOW_XINLINE void set_state(int idx, const std::mt19937 ) {
+states_[idx] = state;
+  }
+
+ private:
+  std::mt19937 states_[kCPURndStateNum];
+};
+
+#if MXNET_USE_CUDA
+
+// at least how many random numbers should be generated by one GPU thread.
+const int kGPUMinRndNumberPerThread = 64;
+// store how many global random states for GPU.
+const int kGPURndStateNum = 32768;
+
+// uniform number generation in Cuda made consistent with stl (include 0 but 
exclude 1)
+// by using 1.0-curand_uniform().
+// Needed as some samplers in sampler.h won't be able to deal with
+// one of the boundary cases.
+template
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
+
+  MSHADOW_FORCE_INLINE __device__ int rand() {
+return curand(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float uniform() {
+return static_cast(1.0) - curand_uniform(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float normal() {
+return curand_normal(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ curandStatePhilox4_32_10_t get_state() {
+return state_;
+  }
+
+ private:
+  curandStatePhilox4_32_10_t state_;
+};
+
+template<>
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
 
 Review comment:
   The implement here was right. It did save the state back in `LaunchRNG`.
   I refactor it to a more readable version.


This is an automated message from the Apache Git Service.
To respond to the 

[GitHub] javelinjs commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
javelinjs commented on a change in pull request #9119: fix random generator: do 
not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158777316
 
 

 ##
 File path: src/operator/mxnet_op.h
 ##
 @@ -448,6 +449,47 @@ struct Kernel {
 #endif
   }
 
+  /*!
+   * \brief Launch a generic CPU kernel with native random generator.
+   * \tparam rnd CPU random generator
+   * \tparam Args Varargs type to eventually pass to the OP::Map() functoion
+   * \param N Number of iterations
+   * \param args Varargs to eventually pass to the OP::Map() functoion
+   */
+  template
+  inline static void LaunchRNG(mshadow::Stream *,
+   common::random::RandGenerator *rnd,
+   const int N, Args... args) {
+using namespace mxnet::common::random;
+#ifdef _OPENMP
+const int omp_threads = std::min(kCPURndStateNum,
+engine::OpenMP::Get()->GetRecommendedOMPThreadCount());
+if (omp_threads < 2) {
 
 Review comment:
   refactored


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


[GitHub] javelinjs commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
javelinjs commented on a change in pull request #9119: fix random generator: do 
not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158777303
 
 

 ##
 File path: src/common/random_generator.h
 ##
 @@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * Copyright (c) 2017 by Contributors
+ * \file random_generator.h
+ * \brief Native random number generator.
+ */
+#ifndef MXNET_COMMON_RANDOM_GENERATOR_H_
+#define MXNET_COMMON_RANDOM_GENERATOR_H_
+
+#include 
+#include 
+#include 
+
+#if MXNET_USE_CUDA
+#include 
+#include 
+#include 
+#endif  // MXNET_USE_CUDA
+
+using namespace mshadow;
+
+namespace mxnet {
+namespace common {
+namespace random {
+
+template
+class RandGenerator;
+
+// Elementary random number generation for int/uniform/gaussian in CPU and GPU.
+// Will use float data type whenever instantiated for half_t or any other non
+// standard real type.
+template
+class RandGeneratorImpl;
+
+// at least how many random numbers should be generated by one CPU thread.
+const int kCPUMinRndNumberPerThread = 64;
+// store how many global random states for CPU.
+const int kCPURndStateNum = 1024;
+
+template
+class RandGeneratorImpl {
+ public:
+  typedef typename std::conditional::type FType;
+
+  explicit RandGeneratorImpl(std::mt19937 *ptr_engine) : 
engine_(ptr_engine) {}
+
+  MSHADOW_XINLINE int rand() { return engine_->operator()(); }
+
+  MSHADOW_XINLINE FType uniform() {
+typedef typename std::conditional::type GType;
+GType dist_uniform;
+return dist_uniform(*engine_);
+  }
+
+  MSHADOW_XINLINE FType normal() {
+std::normal_distribution dist_normal;
+return dist_normal(*engine_);
+  }
+
+ private:
+  std::mt19937 *engine_;
+};
+
+template
+class RandGenerator {
+ public:
+  MSHADOW_XINLINE void dispose() {}
+
+  MSHADOW_XINLINE RandGeneratorImpl Get(int idx = 0) {
+std::mt19937 *ptr_engine = _[idx];
+RandGeneratorImpl gen(ptr_engine);
+return gen;
+  }
+
+  MSHADOW_XINLINE void Seed(Stream *, uint32_t seed) {
+for (int i = 0; i < kCPURndStateNum; ++i) (states_ + i)->seed(seed + i);
+  }
+
+  MSHADOW_XINLINE void set_state(int idx, const std::mt19937 ) {
+states_[idx] = state;
+  }
+
+ private:
+  std::mt19937 states_[kCPURndStateNum];
+};
+
+#if MXNET_USE_CUDA
+
+// at least how many random numbers should be generated by one GPU thread.
+const int kGPUMinRndNumberPerThread = 64;
+// store how many global random states for GPU.
+const int kGPURndStateNum = 32768;
+
+// uniform number generation in Cuda made consistent with stl (include 0 but 
exclude 1)
+// by using 1.0-curand_uniform().
+// Needed as some samplers in sampler.h won't be able to deal with
+// one of the boundary cases.
+template
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
+
+  MSHADOW_FORCE_INLINE __device__ int rand() {
+return curand(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float uniform() {
+return static_cast(1.0) - curand_uniform(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float normal() {
+return curand_normal(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ curandStatePhilox4_32_10_t get_state() {
+return state_;
+  }
+
+ private:
+  curandStatePhilox4_32_10_t state_;
+};
+
+template<>
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
+
+  MSHADOW_FORCE_INLINE __device__ int rand() {
+return curand(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ double uniform() {
+return static_cast(1.0) - curand_uniform_double(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ double normal() {
+return curand_normal_double(_);

[GitHub] TX2012LH commented on issue #9203: compile error in plugin opencv

2017-12-27 Thread GitBox
TX2012LH commented on issue #9203: compile error in plugin opencv
URL: 
https://github.com/apache/incubator-mxnet/issues/9203#issuecomment-354072568
 
 
   Actually I have tried rebuilding and reinstalling mxnet several times. 
Messages are as follows:
   ```
   (mxnet-v0.12.0) ?  opencv git:(master) ? pwd
   /data/xx/mxnet-v0.12.0/plugin/opencv
   (mxnet-v0.12.0) ?  opencv git:(master) ? python
   Python 2.7.14 |Anaconda, Inc.| (default, Nov 20 2017, 18:04:19)
   [GCC 7.2.0] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import mxnet
   mxnet.>>> mxnet.base._LIB
   
   >>> exit()
   (mxnet-v0.12.0) ?  opencv git:(master) ? nm -gC 
/data/xx/mxnet-v0.12.0/python/mxnet/../../lib/libmxnet.so | grep MXCV
   032242e0 T MXCVResize(void*, unsigned int, unsigned int, int, void**)
   032239a0 T MXCVImdecode(unsigned char const*, unsigned int, int, 
void**)
   03224a70 T MXCVcopyMakeBorder(void*, int, int, int, int, int, 
double, void**)
   (mxnet-v0.12.0) ?  opencv git:(master) ? python
   Python 2.7.14 |Anaconda, Inc.| (default, Nov 20 2017, 18:04:19)
   [GCC 7.2.0] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import opencv
   import >>> import numpy as np
   >>> a = np.random.randint(20, size=(30,30,3))
   >>> b = opencv.resize(a, (100,100)
   ... )
   Traceback (most recent call last):
 File "", line 1, in 
 File "opencv.py", line 70, in resize
   check_call(_LIB.MXCVResize(src.handle, mx_uint(size[0]), 
mx_uint(size[1]),
 File 
"/data/xx/anaconda2/envs/mxnet-v0.12.0/lib/python2.7/ctypes/__init__.py", line 
379, in __getattr__
   func = self.__getitem__(name)
 File 
"/data/xx/anaconda2/envs/mxnet-v0.12.0/lib/python2.7/ctypes/__init__.py", line 
384, in __getitem__
   func = self._FuncPtr((name_or_ordinal, self))
   AttributeError: /data/xx/mxnet-v0.12.0/python/mxnet/../../lib/libmxnet.so: 
undefined symbol: MXCVResize
   >>>
   
   ```
   @mwbyeon 


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


[GitHub] TX2012LH commented on issue #9203: compile error in plugin opencv

2017-12-27 Thread GitBox
TX2012LH commented on issue #9203: compile error in plugin opencv
URL: 
https://github.com/apache/incubator-mxnet/issues/9203#issuecomment-354072568
 
 
   Actually I have tried rebuilding and reinstalling mxnet several times. 
Messages are as follows:
   ```
   (mxnet-v0.12.0) ?  opencv git:(master) ? pwd
   /data/xx/mxnet-v0.12.0/plugin/opencv
   (mxnet-v0.12.0) ?  opencv git:(master) ? python
   Python 2.7.14 |Anaconda, Inc.| (default, Nov 20 2017, 18:04:19)
   [GCC 7.2.0] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import mxnet
   mxnet.>>> mxnet.base._LIB
   
   >>> exit()
   (mxnet-v0.12.0) ?  opencv git:(master) ? nm -gC 
/data/xx/mxnet-v0.12.0/python/mxnet/../../lib/libmxnet.so | grep MXCV
   032242e0 T MXCVResize(void*, unsigned int, unsigned int, int, void**)
   032239a0 T MXCVImdecode(unsigned char const*, unsigned int, int, 
void**)
   03224a70 T MXCVcopyMakeBorder(void*, int, int, int, int, int, 
double, void**)
   (mxnet-v0.12.0) ?  opencv git:(master) ? python
   Python 2.7.14 |Anaconda, Inc.| (default, Nov 20 2017, 18:04:19)
   [GCC 7.2.0] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import opencv
   >>> import numpy as np
   >>> a = np.random.randint(20, size=(30,30,3))
   >>> b = opencv.resize(a, (100,100) )
   Traceback (most recent call last):
 File "", line 1, in 
 File "opencv.py", line 70, in resize
   check_call(_LIB.MXCVResize(src.handle, mx_uint(size[0]), 
mx_uint(size[1]),
 File 
"/data/xx/anaconda2/envs/mxnet-v0.12.0/lib/python2.7/ctypes/__init__.py", line 
379, in __getattr__
   func = self.__getitem__(name)
 File 
"/data/xx/anaconda2/envs/mxnet-v0.12.0/lib/python2.7/ctypes/__init__.py", line 
384, in __getitem__
   func = self._FuncPtr((name_or_ordinal, self))
   AttributeError: /data/xx/mxnet-v0.12.0/python/mxnet/../../lib/libmxnet.so: 
undefined symbol: MXCVResize
   >>>
   
   ```
   @mwbyeon 


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


[GitHub] javelinjs commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
javelinjs commented on a change in pull request #9119: fix random generator: do 
not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158776935
 
 

 ##
 File path: src/common/random_generator.h
 ##
 @@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * Copyright (c) 2017 by Contributors
+ * \file random_generator.h
+ * \brief Native random number generator.
+ */
+#ifndef MXNET_COMMON_RANDOM_GENERATOR_H_
+#define MXNET_COMMON_RANDOM_GENERATOR_H_
+
+#include 
+#include 
+#include 
+
+#if MXNET_USE_CUDA
+#include 
+#include 
+#include 
+#endif  // MXNET_USE_CUDA
+
+using namespace mshadow;
+
+namespace mxnet {
+namespace common {
+namespace random {
+
+template
+class RandGenerator;
+
+// Elementary random number generation for int/uniform/gaussian in CPU and GPU.
+// Will use float data type whenever instantiated for half_t or any other non
+// standard real type.
+template
+class RandGeneratorImpl;
+
+// at least how many random numbers should be generated by one CPU thread.
+const int kCPUMinRndNumberPerThread = 64;
+// store how many global random states for CPU.
+const int kCPURndStateNum = 1024;
 
 Review comment:
   changed.


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


[GitHub] javelinjs commented on a change in pull request #9119: fix random generator: do not gen seed each time

2017-12-27 Thread GitBox
javelinjs commented on a change in pull request #9119: fix random generator: do 
not gen seed each time
URL: https://github.com/apache/incubator-mxnet/pull/9119#discussion_r158776959
 
 

 ##
 File path: src/common/random_generator.h
 ##
 @@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * Copyright (c) 2017 by Contributors
+ * \file random_generator.h
+ * \brief Native random number generator.
+ */
+#ifndef MXNET_COMMON_RANDOM_GENERATOR_H_
+#define MXNET_COMMON_RANDOM_GENERATOR_H_
+
+#include 
+#include 
+#include 
+
+#if MXNET_USE_CUDA
+#include 
+#include 
+#include 
+#endif  // MXNET_USE_CUDA
+
+using namespace mshadow;
+
+namespace mxnet {
+namespace common {
+namespace random {
+
+template
+class RandGenerator;
+
+// Elementary random number generation for int/uniform/gaussian in CPU and GPU.
+// Will use float data type whenever instantiated for half_t or any other non
+// standard real type.
+template
+class RandGeneratorImpl;
+
+// at least how many random numbers should be generated by one CPU thread.
+const int kCPUMinRndNumberPerThread = 64;
+// store how many global random states for CPU.
+const int kCPURndStateNum = 1024;
+
+template
+class RandGeneratorImpl {
+ public:
+  typedef typename std::conditional::type FType;
+
+  explicit RandGeneratorImpl(std::mt19937 *ptr_engine) : 
engine_(ptr_engine) {}
+
+  MSHADOW_XINLINE int rand() { return engine_->operator()(); }
+
+  MSHADOW_XINLINE FType uniform() {
+typedef typename std::conditional::type GType;
+GType dist_uniform;
+return dist_uniform(*engine_);
+  }
+
+  MSHADOW_XINLINE FType normal() {
+std::normal_distribution dist_normal;
+return dist_normal(*engine_);
+  }
+
+ private:
+  std::mt19937 *engine_;
+};
+
+template
+class RandGenerator {
+ public:
+  MSHADOW_XINLINE void dispose() {}
+
+  MSHADOW_XINLINE RandGeneratorImpl Get(int idx = 0) {
+std::mt19937 *ptr_engine = _[idx];
+RandGeneratorImpl gen(ptr_engine);
+return gen;
+  }
+
+  MSHADOW_XINLINE void Seed(Stream *, uint32_t seed) {
+for (int i = 0; i < kCPURndStateNum; ++i) (states_ + i)->seed(seed + i);
+  }
+
+  MSHADOW_XINLINE void set_state(int idx, const std::mt19937 ) {
+states_[idx] = state;
+  }
+
+ private:
+  std::mt19937 states_[kCPURndStateNum];
+};
+
+#if MXNET_USE_CUDA
+
+// at least how many random numbers should be generated by one GPU thread.
+const int kGPUMinRndNumberPerThread = 64;
+// store how many global random states for GPU.
+const int kGPURndStateNum = 32768;
+
+// uniform number generation in Cuda made consistent with stl (include 0 but 
exclude 1)
+// by using 1.0-curand_uniform().
+// Needed as some samplers in sampler.h won't be able to deal with
+// one of the boundary cases.
+template
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
+
+  MSHADOW_FORCE_INLINE __device__ int rand() {
+return curand(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float uniform() {
+return static_cast(1.0) - curand_uniform(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ float normal() {
+return curand_normal(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ curandStatePhilox4_32_10_t get_state() {
+return state_;
+  }
+
+ private:
+  curandStatePhilox4_32_10_t state_;
+};
+
+template<>
+class RandGeneratorImpl {
+ public:
+  // Copy state to local memory for efficiency.
+  __device__ explicit RandGeneratorImpl(curandStatePhilox4_32_10_t *state)
+  : state_(*state) {}
+
+  MSHADOW_FORCE_INLINE __device__ int rand() {
+return curand(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ double uniform() {
+return static_cast(1.0) - curand_uniform_double(_);
+  }
+
+  MSHADOW_FORCE_INLINE __device__ double normal() {
+return curand_normal_double(_);