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

error: Tensorflow to caffe "caffe_emitter:emit_Constant" doesn't handle one dim tensor. #599

Closed
Alnlll opened this issue Mar 1, 2019 · 3 comments

Comments

@Alnlll
Copy link

Alnlll commented Mar 1, 2019

Enviroment

Platform (like ubuntu 16.04/win10): ubuntu 16.04

Python version: python3.5

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

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

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

Running scripts:

mmconvert\
  -sf tensorflow\
  -in ../facenet_0330/facenet_0330-eval-ckpt.meta\
  -iw ../facenet_0330/facenet_0330-eval-ckpt\
  --dstNodeName InceptionResnetV1/Bottleneck/BatchNorm/Reshape_1\
  -df caffe\
  -om tf_facenet_0330_se_inception_resnetv1

Problem

Trying to convert a se_inception_resnetv1 from tensorflow to caffe(using master mmdnn), got an IndexError like this:

Traceback (most recent call last):
  File "/usr/local/bin/mmconvert", line 11, in <module>
    sys.exit(_main())
  File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/convert.py", line 108, in _main
    ret = IRToCode._convert(code_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, phase)
  File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/common/DataStructure/emitter.py", line 22, in run
    self.save_code(dstNetworkPath, phase)
  File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/common/DataStructure/emitter.py", line 59, 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 434, in emit_Constant
    shape[1],
IndexError: list index out of range

and got such shape info by adding some print code:

nodename: InceptionResnetV1/Logits/Flatten/flatten/Reshape/shape/1
<class 'graph_pb2.TensorShape'> dim {
  size: 2
}

<class 'list'> [2]

Any idea about this?

@rainLiuplus
Copy link
Contributor

Hi @Alnlll , please use the latest code to have a try, thanks!

@Alnlll
Copy link
Author

Alnlll commented Mar 4, 2019

@rainLiuplus thanks for responding!!
Tried the latest 0.2.4 version, got the same error:

shape1:  dim {
  size: 2
}

shape2:  [2]
Traceback (most recent call last):
  File "/usr/local/bin/mmconvert", line 11, in <module>
    load_entry_point('mmdnn==0.2.4', 'console_scripts', 'mmconvert')()
  File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/convert.py", line 108, in _main
    ret = IRToCode._convert(code_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, phase)
  File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/common/DataStructure/emitter.py", line 22, in run
    self.save_code(dstNetworkPath, phase)
  File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/common/DataStructure/emitter.py", line 59, 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 433, in emit_Constant
    shape[1],
IndexError: list index out of range

And checked the emit_Constant in caffe_emmiter, seems unmodified.

rainLiuplus pushed a commit to rainLiuplus/MMdnn that referenced this issue Mar 4, 2019
rainLiuplus pushed a commit to rainLiuplus/MMdnn that referenced this issue Mar 4, 2019
@Alnlll
Copy link
Author

Alnlll commented Mar 4, 2019

@rainLiuplus Thanks for helping.
Tried this patch, good for my case.

rainLiuplus added a commit that referenced this issue Mar 5, 2019
* fix caffe emit_constant #599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants