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

ValueError: Output tensors to a Model must be the output of a TensorFlow `Layer` #7

Closed zhang-f closed 2 years ago

zhang-f commented 4 years ago

tensorflow==1.12.0 keras==2.2.2

Traceback (most recent call last):
  File "onnx2keras.py", line 556, in <module>
    Fire(main)
  File "/home/fanzh/.conda/envs/neural/lib/python3.6/site-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/fanzh/.conda/envs/neural/lib/python3.6/site-packages/fire/core.py", line 468, in _Fire
    target=component.__name__)
  File "/home/fanzh/.conda/envs/neural/lib/python3.6/site-packages/fire/core.py", line 672, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "onnx2keras.py", line 547, in main
    model = onnx2keras(onnxmodel)
  File "onnx2keras.py", line 539, in onnx2keras
    return tf.keras.models.Model(model_inputs, outputs)
  File "/home/fanzh/.conda/envs/neural/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 121, in __init__
    super(Model, self).__init__(*args, **kwargs)
  File "/home/fanzh/.conda/envs/neural/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py", line 80, in __init__
    self._init_graph_network(*args, **kwargs)
  File "/home/fanzh/.conda/envs/neural/lib/python3.6/site-packages/tensorflow/python/training/checkpointable/base.py", line 474, in _method_wrapper
    method(self, *args, **kwargs)
  File "/home/fanzh/.conda/envs/neural/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py", line 224, in _init_graph_network
    '(thus holding past layer metadata). Found: ' + str(x))
ValueError: Output tensors to a Model must be the output of a TensorFlow `Layer` (thus holding past layer metadata). Found: Tensor("dense/BiasAdd:0", shape=(1, 10), dtype=float32)

Any insights would be appreciated! :)

hakanardo commented 3 years ago

What's the last layer of your model? Any way we could reproduce it? Would moving to tensorflow 2 be an option?

hakanardo commented 3 years ago

Is this still a problem?

95hali74 commented 2 years ago

Closing this issue, please reopen if this is still an issue.