gans-in-action icon indicating copy to clipboard operation
gans-in-action copied to clipboard

Poor DCGAN (chapter 5) performance when upgrading from keras to tf.keras

Open FaizSayyid opened this issue 4 years ago • 1 comments

I'm trying to run the DCGAN from chapter 5; the code performs well and the generated images are good.

But when I change the source code so that it becomes compatible with tf.keras rather than keras, the model produces useless images that are obviously just noise

The following is the only bit of the code I've changed. From:

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

from keras.datasets import mnist
from keras.layers import Activation, BatchNormalization, Dense, Dropout, Flatten, Reshape
from keras.layers import LeakyReLU
from keras.layers import Conv2D, Conv2DTranspose
from keras.models import Sequential
from keras.optimizers import Adam

to:

%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np

from tensorflow.keras.datasets import mnist
from tensorflow.keras.layers import Activation, BatchNormalization, Dense, Dropout, Flatten, Reshape
from tensorflow.keras.layers import LeakyReLU
from tensorflow.keras.layers import Conv2D, Conv2DTranspose
from tensorflow.keras.models import Sequential
from tensorflow.keras.optimizers import Adam

I've even tried to enforce tf_1 compatability with

tf.compat.v1.disable_v2_behavior()

but performance remains poor. Any ideas?

FaizSayyid avatar Nov 09 '20 21:11 FaizSayyid

I faced this too and there is really no answer anywhere but I found that there is a tutorial in tensorflow website.

https://www.tensorflow.org/tutorials/generative/dcgan

Nevermetyou65 avatar Oct 22 '21 10:10 Nevermetyou65