Justobe opened a new issue #17686: Inconsistency between Tensorflow, MXNet and 
Theano backends in LSTM layer
URL: https://github.com/apache/incubator-mxnet/issues/17686
 
 
   ## Description
   
   Hi,I find the inconsistency between  MXNet,Tensorflow and Theano backends in 
LSTM layer when I use a simple lstm model for a regression task. I loaded the 
same model on different backends(tensorflow, mxnet and theano), and the 
prediction accuracy of mxnet is different from that of tensorflow and theano 
under the same input. We calculate the MSE between the output of the model and 
the ground truth. MSE can be calculated as:
   
   
![mse](https://user-images.githubusercontent.com/15032308/75252414-983f5180-5817-11ea-86ef-c845a4484ff2.png)
   
   The MSE values of tensorflow and theano are 0.00015594294981565327 while the 
value of mxnet is 0.5000014050006867.
   
   I put input data into the model and recorded the ouputs of each layers to 
see how this happens. It seems that the outputs on tensorflow and theano are 
very close. But for MXNet, the outputs of the first lstm layer and all the 
layers after this layer are very different from those in tensorflow and theano.
   
   The results are attached below
   
   TensorFlow vs Theano
   
   
![tfth](https://user-images.githubusercontent.com/15032308/75252424-9f665f80-5817-11ea-9c86-c96aefc803b6.png)
   
   
   TensorFlow vs MXNet
   
   
![tf-mx](https://user-images.githubusercontent.com/15032308/75252442-a55c4080-5817-11ea-8725-fec5cb03ecc8.png)
   
   
   Theano vs MXNet 
   
   
![th-mx](https://user-images.githubusercontent.com/15032308/75252457-aa20f480-5817-11ea-9a08-1cc3332304fa.png)
   
   
   The delta column shows the discrepancy, which is calculated as:
   
![MAD](https://user-images.githubusercontent.com/15032308/75252473-b60cb680-5817-11ea-9fe2-b80204da612d.png)
   
   
   Based on the results, the deviation seems to be caused by LSTM of MXNet 
backend.
   
   
   ## To Reproduce
   We attach the .h5 file, input and the code below.
   [code.zip](https://github.com/apache/incubator-mxnet/files/4250250/code.zip)
   
   1. to see the MSE value:
   
      ```
      python get_model_accurary.py [backend name]
      ```
   
   2. to see the output of intermediate layers:
   
      ```
      python get_layers_output.py [backend name]
      ```
   
   3. bug localization:
   
      ```shell
      python get_layers_deviation.py
      ```
   
   ## What have you tried to solve it?
   
   I encountered this problem on mxnet-cu101(Version 1.5.1.post0). When I 
upgraded mxnet to 1.6, the bug still exists.
   
   ## Environment
   
   - MXNet: mxnet-cu101==1.5.1.post0
   - keras-mxnet: 2.2.4.2
   - tensorflow-gpu:1.14.0
   - theano:1.0.4
   - CUDA: 10.1
   
   You can use the following command to configure the environment
   
   ```shell
   pip install keras-mxnet
   pip install mxnet-cu101
   pip install tensorflow-gpu==1.14.0
   pip install theano==1.0.4
   ```

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

Reply via email to