1
$\begingroup$

I have a CNN model which has a lambda layer doing One-Hot encoding of the input. I am trying to remove this Lambda layer after loading the trained network from a h5 file. So far I have tried to create a new model using the output layer of the old one, and old_model.get_layer('Conv1D-First-layer-after-onehot') but I get the following error:

Traceback (most recent call last):
  File "bin/extract_signatures", line 57, in <module>
    outputs=output
  File "/home/ariana/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training.py", line 146, in __init__
    super(Model, self).__init__(*args, **kwargs)
  File "/home/ariana/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/network.py", line 169, in __init__
    self._init_graph_network(*args, **kwargs)
  File "/home/ariana/.local/lib/python3.6/site-packages/tensorflow_core/python/training/tracking/base.py", line 457, in _method_wrapper
    result = method(self, *args, **kwargs)
  File "/home/ariana/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/network.py", line 272, in _init_graph_network
    base_layer_utils.create_keras_history(self._nested_outputs)
  File "/home/ariana/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer_utils.py", line 187, in create_keras_history
    _, created_layers = _create_keras_history_helper(tensors, set(), [])
  File "/home/ariana/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer_utils.py", line 213, in _create_keras_history_helper
    op = tensor.op  # The Op that created this Tensor.
AttributeError: 'Dense' object has no attribute 'op'

I also tried to tie that layer to a newly created Input(), but no change.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.