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

Cannot convert MXNET to Keras #755

Open mzattera opened 5 years ago

mzattera commented 5 years ago

Platform: WinPython under Windows 10

Python version: Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32

1) I installed MMdnn with pip install mmdnn as instructed, however notice this does NOT install the required mxnet package that must be installed separately (I do not know if this is intended).

2) I am trying to convert models from MXNET into Keras. I tried with the VGG16 example as shown below, but I get an assertion failure and conversion stops:

D:\Programs\WinPython\MMdnn\scripts>mmdownload -f mxnet -n vgg16 -o D:\Users\mzatt\Projects\ModelZoo
...
MXNet Model vgg16 saved as [D:\Users\mzatt\Projects\ModelZoo\vgg16-symbol.json] and [D:\Users\mzatt\Projects\ModelZoo\vgg16-0000.params].

D:\Programs\WinPython\MMdnn\scripts>mmconvert -sf mxnet -iw D:\Users\mzatt\Projects\ModelZoo\vgg16-0000.params -in D:\Users\mzatt\Projects\ModelZoo\vgg16-symbol.json -df keras -om D:\Users\mzatt\Projects\ModelZoo\vgg16.h5
[09:51:28] C:\Jenkins\workspace\mxnet-tag\mxnet\src\nnvm\legacy_json_util.cc:209: Loading symbol saved by previous version v0.8.0. Attempting to upgrade...
[09:51:28] C:\Jenkins\workspace\mxnet-tag\mxnet\src\nnvm\legacy_json_util.cc:217: Symbol successfully upgraded!
D:\Programs\WinPython\MMdnn\python-3.5.4.amd64\lib\site-packages\mxnet\module\base_module.py:55: UserWarning: You created Module with Module(..., label_names=['softmax_label']) but input with name 'softmax_label' is not found in symbol.list_arguments(). Did you mean one of:
        data
        prob_label
  warnings.warn(msg)
Traceback (most recent call last):
  File "D:\Programs\WinPython\MMdnn\python-3.5.4.amd64\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "D:\Programs\WinPython\MMdnn\python-3.5.4.amd64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Programs\WinPython\MMdnn\python-3.5.4.amd64\Scripts\mmconvert.exe\__main__.py", line 9, in <module>
  File "D:\Programs\WinPython\MMdnn\python-3.5.4.amd64\lib\site-packages\mmdnn\conversion\_script\convert.py", line 102, in _main
    ret = convertToIR._convert(ir_args)
  File "D:\Programs\WinPython\MMdnn\python-3.5.4.amd64\lib\site-packages\mmdnn\conversion\_script\convertToIR.py", line 80, in _convert
    parser = MXNetParser(model)
  File "D:\Programs\WinPython\MMdnn\python-3.5.4.amd64\lib\site-packages\mmdnn\conversion\mxnet\mxnet_parser.py", line 242, in __init__
    assert isinstance(input_arg[3], list)
AssertionError

Below the list of my installed packages:

D:\Programs\WinPython\MMdnn\scripts>pip list
Package                  Version
------------------------ -------------
absl-py                  0.1.11
adodbapi                 2.6.0.7
alabaster                0.7.10
algopy                   0.5.7
altair                   2.0.0.dev0
altair-widgets           0.1.2
asciitree                0.3.3
asteval                  0.9.12
astor                    0.7.1
astroid                  1.6.2
astroML                  0.3
attrs                    17.4.0
Babel                    2.5.3
backports-abc            0.5
baresql                  0.7.4
bcolz                    1.2.0
beautifulsoup4           4.6.0
blaze                    0.10.1
bleach                   1.5.0
blosc                    1.5.1
bloscpack                0.11.0
bokeh                    0.12.15
Bottleneck               1.2.1
bqplot                   0.10.5
brewer2mpl               1.4.1
Brotli                   1.0.2
certifi                  2018.1.18
cffi                     1.11.5
chardet                  3.0.4
click                    6.7
cloudpickle              0.5.2
clrmagic                 0.0.1a2
colorama                 0.3.9
colorcet                 0.9.1
comtypes                 1.1.4
CVXcanon                 0.1.1
cvxopt                   1.1.9
cvxpy                    0.4.11
cx-Freeze                5.1.1
cycler                   0.10.0
cyordereddict            1.0.0
Cython                   0.28.1
cytoolz                  0.9.0.1
dask                     0.17.2
dask-searchcv            0.2.0
datashader               0.6.5
datashape                0.5.2
db.py                    0.5.3
decorator                4.2.1
dill                     0.2.7.1
distributed              1.21.4
docopt                   0.6.2
docrepr                  0.1.1
docutils                 0.14
ecos                     2.0.5
edward                   1.3.5
emcee                    2.2.1
entrypoints              0.2.3
fast-histogram           0.4
fastcache                1.0.2
fasteners                0.14.1
fastparquet              0.1.4
feather-format           0.4.0
Flask                    0.12.2
Flask-Cors               3.0.3
formlayout               1.1.0
fuzzywuzzy               0.16.0
gast                     0.2.0
geopy                    1.12.0
gmpy2                    2.0.8
graphviz                 0.8.4
greenlet                 0.4.13
grpcio                   1.13.0
guidata                  1.7.6
guiqwt                   3.0.3
h5py                     2.7.1
HeapDict                 1.0.0
holoviews                1.10.0a2
html5lib                 0.9999999
husl                     4.0.3
idlex                    1.13
idna                     2.6
imageio                  2.3.0
imagesize                1.0.0
ipydatawidgets           3.0.0
ipykernel                4.8.2
ipyleaflet               0.7.3
ipympl                   0.1.0
ipyparallel              6.1.1
ipyscales                0.1.3
ipython                  6.2.1
ipython-genutils         0.2.0
ipython-sql              0.3.8
ipywidgets               7.2.0
isort                    4.3.4
itsdangerous             0.24
jedi                     0.11.1
Jinja2                   2.10
joblib                   0.11
jsonschema               2.6.0
julia                    0.1.5
jupyter                  1.0.0
jupyter-client           5.2.3
jupyter-console          5.2.0
jupyter-core             4.4.0
jupyter-sphinx           0.1.2
jupyterlab               0.31.12
jupyterlab-launcher      0.10.5
Keras                    2.1.5
keras-vis                0.4.1
kiwisolver               1.0.1
lazy-object-proxy        1.3.1
llvmlite                 0.22.0
lmfit                    0.9.9
locket                   0.2.0
lxml                     4.2.1
Markdown                 2.6.11
MarkupSafe               1.0
matplotlib               2.2.2
mccabe                   0.6.1
metakernel               0.20.14
mistune                  0.8.3
mizani                   0.4.6
mkl-service              1.1.2
mmdnn                    0.2.5
monotonic                1.4
more-itertools           4.1.0
moviepy                  0.2.3.2
mpl-scatter-density      0.3
mpld3                    0.3
mpldatacursor            0.6.2
mpmath                   1.0.0
msgpack                  0.5.6
msgpack-python           0.5.4+dummy
multipledispatch         0.5.0
multiprocess             0.70.5
mxnet                    1.5.0
mypy                     0.580
mysql-connector-python   8.0.6
nbconvert                5.3.1
nbconvert-reportlab      0.2
nbformat                 4.4.0
netCDF4                  1.3.1
networkx                 2.1
nltk                     3.2.5
notebook                 5.4.1
numba                    0.37.0
numcodecs                0.5.4
numdifftools             0.9.20
numexpr                  2.6.4
numpy                    1.16.5
numpydoc                 0.7.0
oct2py                   4.0.6
octave-kernel            0.28.3
odo                      0.5.0
packaging                17.1
palettable               3.1.0
pandas                   0.22.0
pandas-datareader        0.6.0
pandocfilters            1.4.2
param                    1.5.2
paramnb                  2.0.2
parso                    0.1.1
partd                    0.3.8
patsy                    0.5.0
pdfrw                    0.4
pdvega                   0.1
pep8                     1.7.1
pexpect                  4.4.0
pg8000                   1.11.0
pickleshare              0.7.4
Pillow                   5.0.0
pip                      19.3.1
pkginfo                  1.4.2
plotnine                 0.3.0
pluggy                   0.6.0
prettytable              0.7.2
prompt-toolkit           1.0.15
protobuf                 3.10.0
psutil                   5.4.3
ptpython                 0.41
ptyprocess               0.5.2
PuLP                     1.6.8
py                       1.5.3
pyarrow                  0.9.0
PyAudio                  0.2.11
pybars3                  0.9.3
pybind11                 2.2.2
pycodestyle              2.3.1
pycparser                2.17
pyflakes                 1.6.0
pyflux                   0.4.17
pygame                   1.9.3
Pygments                 2.2.0
pylint                   1.8.3
pymc                     2.3.7
pymc3                    3.3
PyMeta3                  0.5.1
pymongo                  3.6.1
pyodbc                   4.0.22
PyOpenGL                 3.1.2
pypandoc                 1.3.2
pyparsing                2.2.0
PyQt5                    5.9.2
pyqtgraph                0.10.1.dev1
pyserial                 3.4
pystache                 0.5.4
pytest                   3.5.0
python-dateutil          2.7.2
python-hdf4              0.9.1
python-Levenshtein       0.12.0
python-snappy            0.5.2
pythonnet                2.4.0.dev0
PythonQwt                0.5.5
pythreejs                1.0.0
pytz                     2018.3
PyWavelets               0.5.2
pywin32                  223
pywinpty                 0.5.1
pywinusb                 0.4.2
PyYAML                   3.12
pyzmq                    17.0.0
QtAwesome                0.4.4
qtconsole                4.3.1
QtPy                     1.4.0
redis                    2.10.6
regex                    2018.2.21
reportlab                3.4.0
requests                 2.18.4
requests-file            1.4.3
requests-ftp             0.3.1
requests-toolbelt        0.8.0
rope                     0.10.5
rpy2                     2.9.2
Rx                       1.6.1
scikit-fuzzy             0.3.1
scikit-image             0.13.1
scikit-learn             0.19.1
scikit-optimize          0.5.2
scilab2py                0.6.1
scipy                    1.0.1
scs                      1.2.7
seaborn                  0.9.dev0
Send2Trash               1.5.0
setuptools               39.0.1
simplegeneric            0.8.1
simplejson               3.13.2
sip                      4.19.6
six                      1.11.0
snakeviz                 0.4.2
snowballstemmer          1.2.1
sortedcontainers         1.5.9
sounddevice              0.3.10
Sphinx                   1.7.2
sphinx-rtd-theme         0.2.4
sphinxcontrib-websupport 1.0.1
spyder                   3.2.8
SQLAlchemy               1.2.5
sqlite-bro               0.8.11
sqlparse                 0.2.4
statsmodels              0.9.0.dev2
streamz                  0.3.0
supersmoother            0.4
sympy                    1.1.1
tables                   3.4.2
tblib                    1.3.2
tensorboard              1.8.0
tensorflow               1.5.0
tensorflow-gpu           1.8.0
tensorflow-tensorboard   1.5.1
termcolor                1.1.0
terminado                0.8.1
testpath                 0.3.1
Theano                   1.0.1
thrift                   0.11.0
toolz                    0.9.0
tornado                  4.5.3
tqdm                     4.19.9
traitlets                4.3.2
traittypes               0.0.6
twine                    1.11.0
twitter                  1.17.1
typed-ast                1.1.0
urllib3                  1.21.1
vega                     0.5.0
vega-datasets            0.4.1
vega3                    0.5.0
ViTables                 3.0.0
wcwidth                  0.1.7
webencodings             0.5.1
Werkzeug                 0.14.1
wheel                    0.30.0
widgetsnbextension       3.2.0
win-unicode-console      0.5
winpython                1.10.20180404
wordcloud                1.4.1
wrapt                    1.10.11
xarray                   0.10.2
xlrd                     1.1.0
XlsxWriter               1.0.2
xlwings                  0.11.5
zarr                     2.2.0
zict                     0.1.3
rainLiuplus commented 5 years ago

Hi @mzattera, probably you forgot to write the '--inputShape' in your script.