I’m an idiot, the error is not happening in optimize_generator, but in optimize_discriminator, which I called earlier. The equality in shapes succeeded … just not in the function outputting the error.