Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unable to load keras models in tensorflow #21

Open
horstmueller opened this issue Apr 22, 2020 · 0 comments
Open

Unable to load keras models in tensorflow #21

horstmueller opened this issue Apr 22, 2020 · 0 comments

Comments

@horstmueller
Copy link

I am trying to load the pre-trained Keras models using Tensorflow 2.1.0 (Python 3.6.9). I am getting the following err (I also tried tf 1.14 and tf 2.0, same result):

Traceback (most recent call last):
File "test_bagnet.py", line 40, in
model = bagnet17()
File "test_bagnet.py", line 28, in bagnet17
return load_model(model_path)
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/save.py", line 146, in load_model
return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 168, in load_model_from_hdf5
custom_objects=custom_objects)
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/model_config.py", line 55, in model_from_config
return deserialize(config, custom_objects=custom_objects)
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/layers/serialization.py", line 106, in deserialize
printable_module_name='layer')
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/utils/generic_utils.py", line 303, in deserialize_keras_object
list(custom_objects.items())))
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/network.py", line 937, in from_config
config, custom_objects)
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/network.py", line 1903, in reconstruct_from_config
process_node(layer, node_data)
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/network.py", line 1851, in process_node
output_tensors = layer(input_tensors, **kwargs)
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 748, in call
self._maybe_build(inputs)
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 2116, in _maybe_build
self.build(input_shapes)
File "/home/hmueller/venv3/lib/python3.6/site-packages/tensorflow_core/python/keras/layers/core.py", line 1101, in build
raise ValueError('The last dimension of the inputs to Dense '
ValueError: The last dimension of the inputs to Dense should be defined. Found None.

Is there a workaround? In issue #19 you mentioned loading the models in tensorflow successfully, which version did you use?

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

No branches or pull requests

1 participant