Using custom, non-trainable layers in the middle of Keras model yields gradient error #42244
Labels
stat:awaiting response
Status - Awaiting response from author
type:others
issues not falling in bug, perfromance, support, build and install or feature
Problem
I am writing a GAN-style model which uses an untrained / weightless layer in the middle of the GAN (a transformation is performed on the generator output which is then fed into the discriminator). The transformation operation is done with a custom layer, but I'm getting the following error at runtime when trying to train (after compiling both the discriminator and GAN model):
Code
My Custom Layer code is as follows (is meant to convert top left, bottom right coordinates into a square shape):
My Generator code is as follows (turns latent space into top left, bottom right square coordinates then image of square on a canvas):
My Generator + Discriminator (GAN) code is as follows:
And the error shown above occurs when calling
.predict()
on the compiled GAN model.It seems like my ImagePaste Layer is preventing gradients from reaching the generator layers -- how can I get the gradient calculation to ignore the layer (even though its already set to trainable = False) when training? Can anyone help me solve this? Thank you very much.
The text was updated successfully, but these errors were encountered: