I am using the WGAN implementation provided here: https://keras.io/examples/generative/wgan_gp/

And I wanted to save the GAN and its components.

When I do wgan.save("my_folder") I get:

ValueError: Model <__main__.WGAN object at 0x0000022C44F0F190> 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've been able to save the generator and discriminator weights, I can also get the optimizers weights (for the discriminator and generator).

But it's impossible to set the weights for the optimizer.

I tried this: https://stackoverflow.com/questions/49503748/save-and-load-model-optimizer-state

You called set_weights(weights) on optimizer Adam with a weight list of length 11, 
but the optimizer was expecting 0 weights.

I understand that newly created optimizers don't have any weights, and they need to be be trained for at least one round. But everytime the length of the weights of the new optimizer doesn't match with the old one.

Do you have any suggestions ?


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.