fchollet / deep-learning-with-python-notebooks

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

Chapter 12, part 5, GANs - Model cannot be saved because the input shapes have not been set. #175

Open Pappa opened 2 years ago

Pappa commented 2 years ago

Using the code on GANs, I'm unable to save the model in TF SavedModel format. Using TensorFlow 2.6.0 in a Kaggle notebook.

I get the following error:

ValueError: Model <__main__.GAN object at 0x7fa982c57810> cannot be saved because the input 
shapes have not been set. Usually, input shapes are automatically determined from calling 
`.fit()` or `.predict()`. To manually set the shapes, call `model.build(input_shape)`.

I have attempted to resolve this by calling model.build(input_shape) after compilation and adding a call method to the GAN subclass, but I'm still seeing the same issue.