Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from tensorflow to mxnet #30

JackieLeeTHU11 opened this issue Dec 22, 2017 · 6 comments

from tensorflow to mxnet #30

JackieLeeTHU11 opened this issue Dec 22, 2017 · 6 comments


Copy link

JackieLeeTHU11 commented Dec 22, 2017

Hi @kitstar , I want to convert tensorlflow to mxnet. however, I encounter a bug when I run the following script:
python -m mmdnn.conversion._script.IRToCode -f mxnet -d -n converted.pb -w converted.npy

Before that, I get 'imagenet_inception_v3.json', 'imagenet_inception_v3.h5', 'converted.json', 'converted.pb' and 'converted.npy' successfully as the example (from tensorflow to CNTK) provided in the README.

The bug is:
Parse file [converted.pb] with binary format successfully. Detect input layer [input_1] using infer batch size, set it as default value [1] Traceback (most recent call last): File "/usr/lib64/python2.7/", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib64/python2.7/", line 72, in _run_code exec code in run_globals File "/media/disk1/xxx/code/projects/tensorflow-models/MMdnn/mmdnn/conversion/_script/", line 120, in <module> _main() File "/media/disk1/xxx/code/projects/tensorflow-models/MMdnn/mmdnn/conversion/_script/", line 115, in _main ret = _convert(args) File "/media/disk1/xxx/code/projects/tensorflow-models/MMdnn/mmdnn/conversion/_script/", line 56, in _convert, args.dstWeightPath, args.phase) File "mmdnn/conversion/common/DataStructure/", line 21, in run self.save_code(dstNetworkPath, phase) File "mmdnn/conversion/common/DataStructure/", line 53, in save_code code = self.gen_code(phase) File "mmdnn/conversion/mxnet/", line 120, in gen_code dirname = os.path.dirname(self.output_weights_file) File "/home/xxx/softwares/tensorflow/lib64/python2.7/", line 129, in dirname i = p.rfind('/') + 1 AttributeError: 'NoneType' object has no attribute 'rfind'

What is the problem?

Copy link

kitstar commented Dec 22, 2017

For mxnet emitter, you should set a output mxnet checkpoint name, such as
python -m mmdnn.conversion._script.IRToCode -f mxnet -dw mxnet_inception_v3-0000.params ...


Copy link

@kitstar It works well, thanks.

@kitstar kitstar closed this as completed Dec 23, 2017
Copy link

Hi @kitstar , When I convert tensorlflow to mxnet, the following error occurs?

python -m mmdnn.conversion._script.IRToCode -f mxnet --IRModelPath resnet50.pb --dstModelPath --IRWeightPath resnet50.npy -dw mxnet_inception_v3-0000.params

The error is IsADirectoryError: [Errno 21] Is a directory: 'mxnet_inception_v3-0000.params'

Copy link

kitstar commented Apr 18, 2018

Should be fixed in newest mmdnn.

Copy link

"python -m mmdnn.conversion._script.convert -sf tensorflow -iw model-20180402-114759.ckpt-275 -in model-20180402-114759.meta -df mxnet -om mxnet_1.param --dump_tag SERVING"
“TypeError: Cannot convert a tensor of type bool to an input of type string

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Arno\Anaconda3\lib\", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\Arno\Anaconda3\lib\", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Arno\Anaconda3\lib\site-packages\mmdnn\conversion_script\", line 123, in
File "C:\Users\Arno\Anaconda3\lib\site-packages\mmdnn\conversion_script\", line 102, in _main
ret = convertToIR._convert(ir_args)
File "C:\Users\Arno\Anaconda3\lib\site-packages\mmdnn\conversion_script\", line 66, in _convert
parser = TensorflowParser(, args.weights, args.dstNodeName)
File "C:\Users\Arno\Anaconda3\lib\site-packages\mmdnn\conversion\tensorflow\", line 314, in init
tensorflow.import_graph_def(transformed_graph_def, name='', input_map=input_map)
File "C:\Users\Arno\Anaconda3\lib\site-packages\tensorflow\python\util\", line 432, in new_func
return func(*args, **kwargs)
File "C:\Users\Arno\Anaconda3\lib\site-packages\tensorflow\python\framework\", line 671, in import_graph_def
node, 'Input tensor %r %s' % (input_name, te)))
ValueError: graph_def is invalid at node 'enqueue_op': Input tensor 'image_paths:0' Cannot convert a tensor of type bool to an input of type string.”

Copy link

CorvusVaine commented Jun 17, 2021

Hello, is it possible to convert a h5-stored tensorflow model to MXNet or does it have to be a ckpt file ?
Is it possible to get not only the model, but also the MXNet code ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

5 participants