Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ActivationMaximization fails after tf.keras.models.load_model #32

Open
omerbrandis opened this issue Nov 4, 2020 · 1 comment
Open

Comments

@omerbrandis
Copy link

hello,

I've manged to execute the Visualize Dense Layer example.
then tried the following change :

OriginalModel = Model(weights='imagenet', include_top=True)
OriginalModel.summary()
OriginalModel.save('SavedVgg',include_optimizer=True)
model = tf.keras.models.load_model('SavedVgg')
activation_maximization = ActivationMaximization(model, model_modifier, clone=False)

(model is saved in tensorflow checkpoint format )

this fails at runtime
File "DenseLayerVisualization2.py", line 60, in
main()
File "DenseLayerVisualization2.py", line 46, in main
activation = activation_maximization(loss,callbacks=[Print(interval=50)])
File "/usr/local/lib/python3.6/dist-packages/tf_keras_vis/activation_maximization.py", line 92, in call
outputs = self.model(seed_inputs, training=training)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/base_layer.py", line 891, in call
outputs = self.call(cast_inputs, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/saved_model/utils.py", line 57, in return_outputs_and_add_losses
outputs, losses = fn(inputs, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/saved_model/utils.py", line 111, in wrap_with_training_arg
lambda: replace_training_and_call(False))
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/utils/tf_utils.py", line 59, in smart_cond
pred, true_fn=true_fn, false_fn=false_fn, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/smart_cond.py", line 56, in smart_cond
return false_fn()
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/saved_model/utils.py", line 111, in
lambda: replace_training_and_call(False))
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/saved_model/utils.py", line 106, in replace_training_and_call
return wrapped_call(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/def_function.py", line 457, in call
result = self._call(*args, **kwds)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/def_function.py", line 494, in _call
results = self._stateful_fn(*args, **kwds)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/function.py", line 1822, in call
graph_function, args, kwargs = self._maybe_define_function(args, kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/function.py", line 2150, in _maybe_define_function
graph_function = self._create_graph_function(args, kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/function.py", line 2041, in _create_graph_function
capture_by_value=self._capture_by_value),
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/func_graph.py", line 915, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/eager/def_function.py", line 358, in wrapped_fn
return weak_wrapped_fn().wrapped(*args, **kwds)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/saved_model/function_deserialization.py", line 262, in restored_function_body
"\n\n".join(signature_descriptions)))
ValueError: Could not find matching function to call loaded from the SavedModel. Got:
Positional arguments (3 total):
* [<tf.Variable 'Variable:0' shape=(1, 224, 224, 3) dtype=float32>]
* False
* None
Keyword arguments: {}

Expected these arguments to match one of the following 4 option(s):.....

Can anyone help ?

thanks,
Omer.

@keisen
Copy link
Owner

keisen commented Nov 4, 2020

Hi, @omerbrandis .

It seems the cause of the error is OriginalModel.
Just in case, I will examine the cause of the problem.
Could you please submit the code snippet that reproduce the problem?

Thanks!

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

No branches or pull requests

2 participants