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

KeyError: 'ExpandBackward' #6

Open
lastlaugher opened this issue Jan 4, 2018 · 12 comments
Open

KeyError: 'ExpandBackward' #6

lastlaugher opened this issue Jan 4, 2018 · 12 comments

Comments

@lastlaugher
Copy link

I tried "python pytorch2caffe" and I've got below error message.

Traceback (most recent call last):
File "pytorch2caffe.py", line 408, in
os.path.join(output_dir, 'inception_v3-pytorch2caffe.caffemodel'))
File "pytorch2caffe.py", line 37, in pytorch2caffe
net_info = pytorch2prototxt(input_var, output_var)
File "pytorch2caffe.py", line 328, in pytorch2prototxt
add_layer(output_var.grad_fn)
File "pytorch2caffe.py", line 154, in add_layer
top_name = add_layer(u[0])
File "pytorch2caffe.py", line 168, in add_layer
layer['type'] = layer_dict[parent_type]
KeyError: 'ExpandBackward'

My pytorch version is the latest one, http://download.pytorch.org/whl/cu80/torch-0.3.0.post4-cp27-cp27mu-linux_x86_64.whl

@xuzijian
Copy link

I have met same problems. I guess the conversion code has not support 'ExpandBackward' currently.

@jnulzl
Copy link

jnulzl commented Apr 15, 2018

met same problems too!

@wangxc2006
Copy link

same problem, can anybody give some tips?

@lzhaozi
Copy link

lzhaozi commented May 15, 2018

met same problems too!

@autocyz
Copy link

autocyz commented Jun 5, 2018

Let pytorch=0.2, torchvision=0.1.8, the problem will be solved!
I don't kown why, maybe newer pytorch use 'ExpandBackward' to name layer, but older pytorch do not use. And the layer_dict in pytorch2caffe.py do not have 'ExpandBackward'

@wyfdodogod
Copy link

does that mean any model trained in torch version 3 and above need to be retrained in torch 2 and then safe to be converted to caffe

@autocyz
Copy link

autocyz commented Aug 16, 2018

@wyfdodogod I think you needn't retrain in torch 2, you should understand the meaning of ExpandBackward and add this key to layer_dict , then you should add some operater in function pytorch2prototxt, just like elif parent_type == 'BatchNormBackward':

@wyfdodogod
Copy link

@autocyz ty for the explaination, as you mentioned using torch 0.2 and torchvision 0.1.8, i solved the problem more specifically torch0.2 post1 using post2 and 3 might raise error causing python crash at the time caffe is imported.

@ys198918
Copy link

@wangxc2006 did you retrain the model under torch 0.2?

@elepherai
Copy link

Any plan to support 0.4.x ?

@dzyjjpy
Copy link

dzyjjpy commented Apr 11, 2019

@autocyz @longcw met same issue when running demo.py.
when i try to install 0,2.0 by pip install torch==0.2.0 or pip isntall torch-0.2.0.post********.whl
(I try install it based CUDA 9.2 or CUDA 8.0)
errors displays:
is not a supported wheel on this platform
so strange. dose anyone run demo,py sucessfully on torch==0.3.1 and torchvision==0.2.0
I trained model on the env above. thanks

@konioyxgq
Copy link

@autocyz Like you said, "should understand the meaning of ExpandBackward and add this key to layer_dict , then you should add some operater in function pytorch2prototxt, just like elif parent_type == 'BatchNormBackward':"
But i don't know ‘ExpandBackward’ means. So how should it be modified?

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