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

pytorch2keras convert prelu layer fail #121

Open
luan1412167 opened this issue Sep 24, 2020 · 0 comments
Open

pytorch2keras convert prelu layer fail #121

luan1412167 opened this issue Sep 24, 2020 · 0 comments
Labels

Comments

@luan1412167
Copy link

Describe the bug
A clear and concise description of what the bug is.
Hi there,
I'm using your pytorch2keras and facing the following error. Thanks for your support
DEBUG:onnx2keras:###### DEBUG:onnx2keras:... DEBUG:onnx2keras:Converting ONNX operation DEBUG:onnx2keras:type: PRelu DEBUG:onnx2keras:node_name: 338 DEBUG:onnx2keras:node_params: {'change_ordering': True, 'name_policy': 'short'} DEBUG:onnx2keras:... DEBUG:onnx2keras:Check if all inputs are available: DEBUG:onnx2keras:Check input 0 (name 336). DEBUG:onnx2keras:Check input 1 (name 337). DEBUG:onnx2keras:... found all, continue Traceback (most recent call last): File "/home/dmp/Silent-Face-Anti-Spoofing/src/utils/cvtpytorch2keras.py", line 134, in <module> k_model = pytorch_to_keras(anti_model.model, input_var, input_shapes=[(3, 112, 112,)], change_ordering=True, verbose=True, name_policy='short') File "/home/dmp/Downloads/pytorch2keras/pytorch2keras/converter.py", line 83, in pytorch_to_keras verbose=verbose, change_ordering=change_ordering) File "/home/dmp/Silent-Face-Anti-Spoofing/luandd/lib/python3.6/site-packages/onnx2keras-0.0.22-py3.6.egg/onnx2keras/converter.py", line 181, in onnx_to_keras keras_names File "/home/dmp/Silent-Face-Anti-Spoofing/luandd/lib/python3.6/site-packages/onnx2keras-0.0.22-py3.6.egg/onnx2keras/activation_layers.py", line 173, in convert_prelu layers[node_name] = prelu(input_0) File "/home/dmp/Silent-Face-Anti-Spoofing/luandd/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 824, in __call__ self._maybe_build(inputs) File "/home/dmp/Silent-Face-Anti-Spoofing/luandd/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 2153, in _maybe_build self.set_weights(self._initial_weights) File "/home/dmp/Silent-Face-Anti-Spoofing/luandd/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 1341, in set_weights 'provided weight shape ' + str(w.shape)) ValueError: Layer weight shape (1, 1, 56) not compatible with provided weight shape (32, 1, 1)

To Reproduce
Snippet of your code
`
input_np = np.random.uniform(0, 1, (1, 3, 112, 112))
input_var = Variable(torch.FloatTensor(input_np))

k_model = pytorch_to_keras(anti_model.model, input_var, input_shapes=[(3, 112, 112,)], change_ordering=True, verbose=True, name_policy='short') 

`
This is my pytorch model https://drive.google.com/file/d/18NMAcPh2ZJwaWZZ-JxvZZOWOllskygSq/view?usp=sharing
Expected behavior
A clear and concise description of what you expected to happen.

Logs
If applicable, add error message to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Python [e.g. Python 2, Python 3]
  • Version [e.g. v0.1.11]

Additional context
Add any other context about the problem here.

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

No branches or pull requests

1 participant