jeffheaton / t81_558_deep_learning

T81-558: Keras - Applications of Deep Neural Networks @Washington University in St. Louis
https://sites.wustl.edu/jeffheaton/t81-558/
Other
5.72k stars 3.03k forks source link

07_2_Keras_gan Input shape mismatch #30

Closed KevinOfCathay closed 4 years ago

KevinOfCathay commented 5 years ago

The code works fine when GENERATE_RES = 2. But when GENERATE_RES = 3, the generator outputs an image of (128, 128, 3), whereas the discriminator should receive an (96, 96, 3) image. Here is an summary of generator when GENERATE_RES = 3: Layer (type) Output Shape Param #

dense_2 (Dense) (None, 4096) 413696

reshape_1 (Reshape) (None, 4, 4, 256) 0

up_sampling2d_1 (UpSampling2 (None, 8, 8, 256) 0

conv2d_6 (Conv2D) (None, 8, 8, 256) 590080

batch_normalization_5 (Batch (None, 8, 8, 256) 1024

activation_1 (Activation) (None, 8, 8, 256) 0

up_sampling2d_2 (UpSampling2 (None, 16, 16, 256) 0

conv2d_7 (Conv2D) (None, 16, 16, 256) 590080

batch_normalization_6 (Batch (None, 16, 16, 256) 1024

activation_2 (Activation) (None, 16, 16, 256) 0

up_sampling2d_3 (UpSampling2 (None, 32, 32, 256) 0

conv2d_8 (Conv2D) (None, 32, 32, 128) 295040

batch_normalization_7 (Batch (None, 32, 32, 128) 512

activation_3 (Activation) (None, 32, 32, 128) 0

up_sampling2d_4 (UpSampling2 (None, 64, 64, 128) 0

conv2d_9 (Conv2D) (None, 64, 64, 128) 147584

batch_normalization_8 (Batch (None, 64, 64, 128) 512

activation_4 (Activation) (None, 64, 64, 128) 0

up_sampling2d_5 (UpSampling2 (None, 128, 128, 128) 0

conv2d_10 (Conv2D) (None, 128, 128, 128) 147584

batch_normalization_9 (Batch (None, 128, 128, 128) 512

activation_5 (Activation) (None, 128, 128, 128) 0

conv2d_11 (Conv2D) (None, 128, 128, 3) 3459

activation_6 (Activation) (None, 128, 128, 3) 0


Also, the summary of generator when GENERATE_RES = 2:

Layer (type) Output Shape Param #

dense_2 (Dense) (None, 4096) 413696

reshape_1 (Reshape) (None, 4, 4, 256) 0

up_sampling2d_1 (UpSampling2 (None, 8, 8, 256) 0

conv2d_6 (Conv2D) (None, 8, 8, 256) 590080

batch_normalization_5 (Batch (None, 8, 8, 256) 1024

activation_1 (Activation) (None, 8, 8, 256) 0

up_sampling2d_2 (UpSampling2 (None, 16, 16, 256) 0

conv2d_7 (Conv2D) (None, 16, 16, 256) 590080

batch_normalization_6 (Batch (None, 16, 16, 256) 1024

activation_2 (Activation) (None, 16, 16, 256) 0

up_sampling2d_3 (UpSampling2 (None, 32, 32, 256) 0

conv2d_8 (Conv2D) (None, 32, 32, 128) 295040

batch_normalization_7 (Batch (None, 32, 32, 128) 512

activation_3 (Activation) (None, 32, 32, 128) 0

up_sampling2d_4 (UpSampling2 (None, 64, 64, 128) 0

conv2d_9 (Conv2D) (None, 64, 64, 128) 147584

batch_normalization_8 (Batch (None, 64, 64, 128) 512

activation_4 (Activation) (None, 64, 64, 128) 0

conv2d_10 (Conv2D) (None, 64, 64, 3) 3459

activation_5 (Activation) (None, 64, 64, 3) 0

jeffheaton commented 5 years ago

Thanks, I will have a look.

jeffheaton commented 4 years ago

This is probably fixed now. I still need to add more documentation in the notebook, and will close out once I do that.