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.79k stars 965 forks source link

in emit_Concat axis = axis_array.index(IR_node.get_attr('axis')) ValueError: tuple.index(x): x not in tuple #469

Open PapaMadeleine2022 opened 5 years ago

PapaMadeleine2022 commented 5 years ago

hello, when I run

mmconvert -sf tensorflow -iw /xxx/my_mobilenet2.pb --inNodeName input_images --inputShape 1000,1000,3 --dstNodeName model_0/feature_fusion/scores/Sigmoid -df caffe -om tf_resnet

I get error:

...
R network structure is saved as [57e120c6abd14cdf9a6c80d0671c8b4e.json].
IR network structure is saved as [57e120c6abd14cdf9a6c80d0671c8b4e.pb].
IR weights are saved as [57e120c6abd14cdf9a6c80d0671c8b4e.npy].
Parse file [57e120c6abd14cdf9a6c80d0671c8b4e.pb] with binary format successfully.
Warning: Graph Construct a self-loop node model_0/sub_1/y. Ignored.
Warning: Graph Construct a self-loop node model_0/sub_2/y. Ignored.
Warning: Graph Construct a self-loop node model_0/sub/y. Ignored.
CaffeEmitter has not supported operator [Split].
model_0/split
Traceback (most recent call last):
  File "/xxx/.virtualenvs/mmdnn/bin/mmconvert", line 11, in <module>
    sys.exit(_main())
  File "/xxx/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/_script/convert.py", line 108, in _main
    ret = IRToCode._convert(code_args)
  File "/xxx/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/_script/IRToCode.py", line 61, in _convert
    emitter.run(args.dstModelPath, args.dstWeightPath, args.phase)
  File "/xxx/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/caffe/caffe_emitter.py", line 144, in run
    super(CaffeEmitter, self).run(dstNetworkPath, dstWeightPath, phase)
  File "/xxx/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/common/DataStructure/emitter.py", line 21, in run
    self.save_code(dstNetworkPath, phase)
  File "/xxx/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/common/DataStructure/emitter.py", line 53, in save_code
    code = self.gen_code(phase)
  File "/xxx/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/caffe/caffe_emitter.py", line 132, in gen_code
    func(current_node)
  File "/xxx/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/caffe/caffe_emitter.py", line 460, in emit_Concat
    axis = axis_array.index(IR_node.get_attr('axis'))
ValueError: tuple.index(x): x not in tuple

but when I run

mmconvert -sf tensorflow -in /xxx/my_mobilenet2.ckpt-713491.meta -iw /xxx/my_mobilenet2.ckpt-713491 --dstNodeName model_0/feature_fusion/scores/Sigmoid -df caffe -om tf_resnet

it shows another error:

...
Tensorflow checkpoint file [/xxx/my_mobilenet2.ckpt-713491] loaded successfully. [1093] variables loaded.
2018-10-25 18:37:43.249422: I tensorflow/tools/graph_transforms/transform_graph.cc:264] Applying fold_constants
Traceback (most recent call last):
  File "/zzz/.virtualenvs/mmdnn/bin/mmconvert", line 11, in <module>
    sys.exit(_main())
  File "/zzz/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/_script/convert.py", line 102, in _main
    ret = convertToIR._convert(ir_args)
  File "/zzz/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/_script/convertToIR.py", line 66, in _convert
    parser = TensorflowParser(args.network, args.weights, args.dstNodeName)
  File "/zzz/.virtualenvs/mmdnn/lib/python2.7/site-packages/mmdnn/conversion/tensorflow/tensorflow_parser.py", line 256, in __init__
    tensorflow.import_graph_def(transformed_graph_def, name='', input_map=input_map)
  File "/search/odin/gongzhenting/.virtualenvs/mmdnn/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 432, in new_func
    return func(*args, **kwargs)
  File "/zzz/.virtualenvs/mmdnn/lib/python2.7/site-packages/tensorflow/python/framework/importer.py", line 493, in import_graph_def
    raise ValueError(str(e))
ValueError: Dimension 1 in both shapes must be equal, but are 2 and 1. Shapes are [1,2,2] and [1,1,1]. for 'model_0/feature_fusion/concat' (op: 'ConcatV2') with input shapes: [1,2,2,960], [1,1,1,72], [] and with computed input tensors: input[2] = <-1>.

my tf is 1.8 and mmdnn is 0.2.3, so how to fix it? thank you very much~

my my_mobilenet2.pb, my_mobilenet2.ckpt-713491.meta and my_mobilenet2.ckpt-713491 is here.

payal211 commented 4 years ago

I have the same error. Anyone can please help.

Thanks in advance.

Traceback (most recent call last): File "/usr/local/bin/mmtocode", line 8, in sys.exit(_main()) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/IRToCode.py", line 117, in _main ret = _convert(args) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/IRToCode.py", line 61, in _convert emitter.run(args.dstModelPath, args.dstWeightPath, args.phase) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/caffe/caffe_emitter.py", line 144, in run super(CaffeEmitter, self).run(dstNetworkPath, dstWeightPath, args.phase) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/common/DataStructure/emitter.py", line 21, in run self.save_code(dstNetworkPath, phase) File "/usr/local/lib/mmdnn/lib/python3.5/dist-packages/mmdnn/conversion/common/DataStructure/emitter.py", line 55, in save_code code = self.gen_code(phase) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/caffe/caffe_emitter.py", line 132, in gen_code func(current_node) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/caffe/caffe_emitter.py", line 516, in emit_Concat axis = axis_array.index(IR_node.get_attr('axis')) ValueError: tuple.index(x): x not in tuple

payal211 commented 4 years ago

@IvyGongoogle have you solve it? What was the issue for this?

Thank you very much.