icemelon9 opened a new issue #17479: Bug in RNN and LSTM with multiple layers for mxnet-mkl URL: https://github.com/apache/incubator-mxnet/issues/17479 ## Description When `gluon.rnn.RNN` and `gluon.rnn.LSTM` have multiple layers and input size is not equal to hidden size, the output tensors and output states (except the state for the first layer) are incorrect. This bug only appears in mxnet-mkl package (I checked 1.5.0, 1.5.1, and 1.6.0, all have this bug), not in mxnet package. ### Error Message (Paste the complete error message. Please also include stack trace by setting environment variable `DMLC_LOG_STACK_TRACE_DEPTH=10` before running your script.) ## To Reproduce mxnet and mxnet-mkl returns different output results for the following code, where the results from mxnet-mkl are wrong. ```python import numpy as np import mxnet as mx from mxnet import gluon np.random.seed(0) mx.random.seed(0) dtype = 'float32' batch = 1 seq_len = 3 hidden_size = 10 input_size = 5 num_layers = 2 data_shape = (seq_len, batch, input_size) state_shape = (num_layers, batch, hidden_size) layer = gluon.rnn.RNN(hidden_size, num_layers, input_size=input_size, bidirectional=False) num_states = 1 # layer = gluon.rnn.LSTM(hidden_size, num_layers, bidirectional=False) # num_states = 2 layer.initialize() layer.hybridize() data_np = np.random.uniform(size=data_shape).astype(dtype) data_mx = mx.nd.array(data_np) states_mx = [] for i in range(num_states): s = np.random.uniform(size=state_shape).astype(dtype) states_mx.append(mx.nd.array(s)) mx_out, mx_states = layer(data_mx, states_mx) print(mx_out.asnumpy()) print(mx_states[0].asnumpy()) ``` ### Steps to reproduce (Paste the commands you ran that produced the error.) 1. 2. ## What have you tried to solve it? 1. 2. ## Environment We recommend using our script for collecting the diagnositc information. Run the following command and paste the outputs below: ``` curl --retry 10 -s https://raw.githubusercontent.com/dmlc/gluon-nlp/master/tools/diagnose.py | python # paste outputs here ----------Python Info---------- Version : 3.7.3 Compiler : GCC 7.3.0 Build : ('default', 'Mar 27 2019 22:11:17') Arch : ('64bit', '') ------------Pip Info----------- Version : 19.3.1 Directory : /home/ubuntu/anaconda3/lib/python3.7/site-packages/pip ----------MXNet Info----------- Version : 1.5.0 Directory : /home/ubuntu/anaconda3/lib/python3.7/site-packages/mxnet Num GPUs : 0 Commit Hash : 75a9e187d00a8b7ebc71412a02ed0e3ae489d91f ----------System Info---------- Platform : Linux-4.15.0-1057-aws-x86_64-with-debian-buster-sid system : Linux node : ip-172-31-24-84 release : 4.15.0-1057-aws version : #59-Ubuntu SMP Wed Dec 4 10:02:00 UTC 2019 ----------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): 8 On-line CPU(s) list: 0-7 Thread(s) per core: 2 Core(s) per socket: 4 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: 2215.251 CPU max MHz: 3000.0000 CPU min MHz: 1200.0000 BogoMIPS: 4600.10 Hypervisor vendor: Xen Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 46080K NUMA node0 CPU(s): 0-7 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 cpuid aperfmperf 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 cpuid_fault invpcid_single pti 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.4746 sec. Timing for GluonNLP GitHub: https://github.com/dmlc/gluon-nlp, DNS: 0.0005 sec, LOAD: 0.3909 sec. Timing for GluonNLP: http://gluon-nlp.mxnet.io, DNS: 0.1271 sec, LOAD: 0.3758 sec. Timing for D2L: http://d2l.ai, DNS: 0.0084 sec, LOAD: 0.0419 sec. Timing for D2L (zh-cn): http://zh.d2l.ai, DNS: 0.0089 sec, LOAD: 0.0692 sec. Timing for FashionMNIST: https://repo.mxnet.io/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0527 sec, LOAD: 0.1357 sec. Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0113 sec, LOAD: 0.3577 sec. Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0093 sec, LOAD: 0.0664 sec. ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
