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

conversion simple model from keras to caffe #222

Closed RPastorino closed 6 years ago

RPastorino commented 6 years ago

Platform (like ubuntu 16.04/win10): macOS High Sierra 10.13.4

Python version: 2.7.14

Source framework with version (like Tensorflow 1.4.1 with GPU): keras 2.1.6

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

Pre-trained model path (webpath or webdisk path):

Running scripts: mmconvert -sf keras -im /pathToModel/myModel.h5 -df caffe -om /pathToModel/myModel.prototxt

This is the error trace I got.

/Users/riccardopastorino/anaconda2/lib/python2.7/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Using TensorFlow backend. Traceback (most recent call last): File "/Users/riccardopastorino/anaconda2/bin/mmconvert", line 11, in sys.exit(_main()) File "/Users/riccardopastorino/anaconda2/lib/python2.7/site-packages/mmdnn/conversion/_script/convert.py", line 95, in _main ret = convertToIR._convert(ir_args) File "/Users/riccardopastorino/anaconda2/lib/python2.7/site-packages/mmdnn/conversion/_script/convertToIR.py", line 39, in _convert parser = Keras2Parser(model) File "/Users/riccardopastorino/anaconda2/lib/python2.7/site-packages/mmdnn/conversion/keras/keras2_parser.py", line 104, in init assert False AssertionError

the model is a simple MNIST classifier with few reLUs' layers and a softmax layer

kitstar commented 6 years ago

Hi @RPastorino, could you try to modify the command

-im /pathToModel/myModel.h5

-->

-iw /pathToModel/myModel.h5
RPastorino commented 6 years ago

Hi @kitstar, Thanks for your reply! with -iw it seems to try to convert the model. Now i have an issue with caffe that it ain't imported and the shell displays me: ImportError: No module named caffe Btw, thanks again

RPastorino commented 6 years ago

I can confirm that with keras and caffe well installed the mmconversion: mmconvert -sf keras -iw /pathToModel/myModel.h5 -df caffe -om /pathToModel/myModel.prototxt works fine