microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.
MIT License
5.8k stars 965 forks source link

LSTM support for MXNet Emitter #634

Open sharmalakshay93 opened 5 years ago

sharmalakshay93 commented 5 years ago

I'm trying to convert a Keras model with some LSTM layers to an MXNet equivalent by running the command mmconvert -sf keras -iw audio_model.h5 -df mxnet -om keras_to_mxnet_mmdnn.dnn ; the python script containing RefactorModel (and some other files) appear to be created fine, but the following exception is being thrown (contains a few extra lines that I logged out):

MXNet Emitter has not supported operator [LSTM].
lstm_22
type(IR_node): <class 'mmdnn.conversion.common.IR.IR_graph.IRGraphNode'>
IR_node.variable_name:  lstm_22_activation
Target network code snippet is saved as [db1ec0b5e7ac46e2815e951b4076dff9.py].
Traceback (most recent call last):
  File "/Users/slakshay/anaconda3/bin/mmconvert", line 10, in <module>
    sys.exit(_main())
  File "/Users/slakshay/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/convert.py", line 112, in _main
    dump_code(args.dstFramework, network_filename + '.py', temp_filename + '.npy', args.outputModel, args.dump_tag)
  File "/Users/slakshay/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/_script/dump_code.py", line 32, in dump_code
    save_model(MainModel, network_filepath, weight_filepath, dump_filepath)
  File "/Users/slakshay/anaconda3/lib/python3.6/site-packages/mmdnn/conversion/mxnet/saver.py", line 2, in save_model
    model = MainModel.RefactorModel()
  File "db1ec0b5e7ac46e2815e951b4076dff9.py", line 10, in RefactorModel
    lstm_21_activation = mx.sym.Activation(data = lstm_21, act_type = 'tanh', name = 'lstm_21_activation')
NameError: name 'lstm_21' is not defined

Is this because LSTM is simply not supported for MXNet conversions? Or is there something that I might be doing incorrectly? Thanks!

Platform (like ubuntu 16.04/win10): Mac OS Sierra 10.12.6

Python version: 3.6

Source framework with version (like Tensorflow 1.4.1 with GPU): Keras

Destination framework with version (like CNTK 2.3 with GPU): MXNet

Pre-trained model path (webpath or webdisk path): locally stored and self-created

Running scripts:

JiahaoYao commented 5 years ago

Hi @sharmalakshay93, I think it is just because the LSTM is not supported currently for MMdnn.

eloi-loomai commented 5 years ago

When will the mmdnn team will work on that? I have a problem on my end too on that.

rainLiuplus commented 5 years ago

Hi @eloi-loomai, if your source is TensorFlow, mmdnn supports it.

eloi-loomai commented 5 years ago

Ok, unfortunately my source is pytorch