You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tested your repo with the included lenet.py example and this works fine up until and including TF V2.3.0 (I use tf.keras). I also tried TF V2.4.0 and V2.5.0 which both gave me the following error:
Traceback (most recent call last):
File "lenet.py", line 110, in <module>
main()
File "lenet.py", line 81, in main
model = delete_channels(model, layer, high_apoz_channels)
File "/home/maarten/.virtualenvs/easics_colonoscopy/lib/python3.7/site-packages/kerassurgeon/operations.py", line 105, in delete_channels
return surgeon.operate()
File "/home/maarten/.virtualenvs/easics_colonoscopy/lib/python3.7/site-packages/kerassurgeon/surgeon.py", line 155, in operate
sub_output_nodes)
File "/home/maarten/.virtualenvs/easics_colonoscopy/lib/python3.7/site-packages/kerassurgeon/surgeon.py", line 278, in _rebuild_graph
outputs, output_masks = zip(*[_rebuild_rec(n) for n in output_nodes])
File "/home/maarten/.virtualenvs/easics_colonoscopy/lib/python3.7/site-packages/kerassurgeon/surgeon.py", line 278, in <listcomp>
outputs, output_masks = zip(*[_rebuild_rec(n) for n in output_nodes])
File "/home/maarten/.virtualenvs/easics_colonoscopy/lib/python3.7/site-packages/kerassurgeon/surgeon.py", line 215, in _rebuild_rec
node_output = utils.single_element(node.output_tensors)
File "/home/maarten/.virtualenvs/easics_colonoscopy/lib/python3.7/site-packages/kerassurgeon/utils.py", line 144, in single_element
if len(x) == 1:
File "/home/maarten/.virtualenvs/easics_colonoscopy/lib/python3.7/site-packages/tensorflow/python/keras/engine/keras_tensor.py", line 221, in __len__
raise TypeError('Keras symbolic inputs/outputs do not '
TypeError: Keras symbolic inputs/outputs do not implement `__len__`. You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. This error will also get raised if you try asserting a symbolic input/output directly.
What can be done to fix this?
The text was updated successfully, but these errors were encountered:
maartenvds
changed the title
Deleting channels with TF V2.4.0 and onwards break
Deleting channels with TF V2.4.0 and onwards breaks
Jul 26, 2021
@Raukk the original keras surgeon project does not seem to be maintained anymore.
I've tested every version of TF > 2.0.
Even including both Pull Requests from the original repo that fix different TF > 2.0 issues
(Also the __len__ issues described by this issue)
Once non Conv2D layers are used, kerassurgeon does not work anymore.
# is fine and can be pruned with kerassurgeon and TF > 2.0
model = tf.keras.Sequential([
tf.keras.layers.Conv2D(5, (3,3)),
tf.keras.layers.Conv2D(2, (3,3))
])
Hi,
I tested your repo with the included lenet.py example and this works fine up until and including TF V2.3.0 (I use tf.keras). I also tried TF V2.4.0 and V2.5.0 which both gave me the following error:
What can be done to fix this?
The text was updated successfully, but these errors were encountered: