I am trying to save a GAN model so that I can continue the training later.
Basically I am saving the discriminator and generator separately after the training loop, with these commands:
discriminator.save("discriminatorTrained.h5")
generator.save("generatorTrained.h5")
Then when I want to continue training I am loading them like this:
# Load Discriminator and Generator
discriminator = load_model('discriminatorTrained.h5')
generator = load_model('generatorTrained.h5')
discriminator.trainable = False
And then I am making a new GAN with the loaded discriminator and generator like this:
#Make new GAN from trained discriminator and generator
gan_input = Input(shape=(noise_dim,))
fake_image = generator(gan_input)
gan_output = discriminator(fake_image)
gan = Model(gan_input, gan_output)
gan.compile(loss='binary_crossentropy', optimizer=optimizer)
And then run the same training script as I did from the start.
I don't get any error message, and it seems to work, however, if comparing the results, for example saving and loading and continue training 10 times, seems to produce less good results from the generator, than if I just run a single training for 10 as many epochs.
So I am suspecting, that I might be missing something here, is some training information lost in this process, perhaps in the recreation of the GAN model?