fchollet / deep-learning-with-python-notebooks

Jupyter notebooks for the code samples of the book "Deep Learning with Python"
MIT License
18.17k stars 8.53k forks source link

7.2.1 Writing your own callbacks #91

Open okbalefthanded opened 5 years ago

okbalefthanded commented 5 years ago

While running the notebook provided by Claude Coulombe for Ch7 in the section writing your own callabacks (reporting issues is disabled on the forked repo), the model.fit() crushes while completing the 1st epoch. the error is related to the custom callback ActivationLogger in the method _on_epochend when computing the activation:

validation_sample_x = self.validation_data[0][0:1] validation_sample_y = self.validation_data[1] activations = self.activations_model.predict(validation_sample_x)

the last error message is:

InvalidArgumentError: images:0 is both fed and fetched.

Running the notebook on: Google Colaboratory Keras 2.2.4 TensorFlow 1.12.0

morenoh149 commented 5 years ago

can you share a colab link?

cc @ClaudeCoulombe

okbalefthanded commented 5 years ago

here's the notebook with the runtime output:

https://drive.google.com/file/d/1uqSrzaXfnOvObwj-xPTLczlOu8Z3AcO4/view?usp=sharing

ClaudeCoulombe commented 5 years ago

Greetings folks, The Notebook was working with Keras 2.0.9 and TensorFlow 1.11.0 but I agree it's not working with Keras 2.2.4 and TensorFlow 1.12.0. Sorry, but I've no time to investigate more today.

morenoh149 commented 5 years ago

well images is the layer defined as model_input = layers.Input(shape=(28, 28, 1), dtype='float32', name='images')

If you search for 0 is both fed and fetched. you get solutions like https://stackoverflow.com/questions/37076208/tensorflow-invalid-argument-reshape0-is-both-fed-and-fetched which say "You can not have a Tensor that is both fed and fetched. The work-around is to add "tf.identity" op and fetch that"

try some of the stackoverflow solutions to this error, somewhere in the code a reuse operation is being made, this should be an identity (use a copy) operation instead.