AxisCommunications / onnx-to-keras

Convert onnx models exported from pytorch to tensorflow keras models with focus on performace and highleve compatibility.
MIT License
25 stars 13 forks source link

AttributeError: Current node is not in weights / model inputs / layers #10

Open Roberto7766 opened 3 years ago

Roberto7766 commented 3 years ago

Using:

_import onnx from onnx2keras import onnx_to_keras import tensorflow as tf import shutil onnx_model = onnx.load('model.onnx') k_model = onnx_to_keras(onnx_model=onnx_model, input_names=['data'], change_ordering=True) shutil.rmtree('saved_model', ignore_errors=True) tf.saved_model.save(k_model, 'savedmodel')

I obtain the following result:

INFO:onnx2keras:Converter is called. DEBUG:onnx2keras:List input shapes: DEBUG:onnx2keras:None DEBUG:onnx2keras:List inputs: DEBUG:onnx2keras:Input 0 -> input.1. DEBUG:onnx2keras:List outputs: DEBUG:onnx2keras:Output 0 -> 1048. [...] DEBUG:onnx2keras:Check if all inputs are available: DEBUG:onnx2keras:Check input 0 (name input.1). DEBUG:onnx2keras:The input not found in layers / model inputs. [....] AttributeError: Current node is not in weights / model inputs / layers.

I suppose the issue is related to NN input. Shall I modify the input in some way to move forward? How? Thank you.

Roberto7766 commented 3 years ago

Sorry, I made a mistake, the issue was for the input_names field. I should have used input_names=['input.1']. If I use the correct value, everything goes smooth until I obtain:

ValueError: Operands could not be broadcast together with shapes (32, 16, 96) (96, 1, 96) Any suggestion?

hakanardo commented 3 years ago

Can you share a minimal network we could use to reporduce this?