DV Dis
DV Dis
DV Dis
KI = keras.initializers.RandomNormal(mean=0.0, stddev=0.02)
input_dim = 300
def Generator_Model():
Generator = Sequential()
Generator.add(ReLU())
Generator.add(Reshape((8, 8, 512)))
return Generator
generator = Generator_Model()
generator.summary()
keras.utils.plot_model(generator, show_shapes=True)
…………………………………………………………………………………………………………………………………………………………
def Discriminator_Model():
discriminator = Sequential()
discriminator.add(MaxPooling2D(pool_size=(2, 2)))
discriminator.add(MaxPooling2D(pool_size=(2, 2)))
discriminator.add(MaxPooling2D(pool_size=(2, 2)))
discriminator.add(Flatten())
discriminator.add(Dense(256, activation='LeakyReLU'))
discriminator.add(Dense(1, activation='sigmoid'))
return discriminator
discriminator = Discriminator_Model()
discriminator.summary()
keras.utils.plot_model(discriminator, show_shapes=True)
……………………………………………………………………………………………………………………………………………………………
Member 4th - Training Loop and Model Evaluation
class DCGAN(keras.Model):
# ...
class DCGANMonitor(keras.callbacks.Callback):
# ...
epochs = 30
lr_g = 0.0003
lr_d = 0.0001
beta = 0.5
latent_dim = 300
dcgan.compile(g_optimizer=Adam(learning_rate=lr_g, beta_1=beta),
d_optimizer=Adam(learning_rate=lr_g, beta_1=beta), loss_fn=BinaryCrossentropy())
plt.figure(figsize=(40, 40))
d_loss_values = history.history['d_loss']
g_loss_values = history.history['g_loss']
create_loss_figure(d_loss_values, g_loss_values)
…………………………………………………………………………………………………………………………………………………………
import numpy as np
import tensorflow as tf
import warnings
warnings.filterwarnings('ignore')
# Loading and Preparing Anime Face Images Dataset using Keras Image Data Generator
batchsize = 32
train = keras.utils.image_dataset_from_directory(
directory='/kaggle/input/anime-faces/data',
batch_size=batchsize,
image_size=(img_width, img_height))
batch = data_iterator.next()
ax[idx].imshow(img.astype(int))
ax[idx].title.set_text(batch[1][idx])
train_generator = train_datagen.flow_from_directory(
DIR,
target_size=(64, 64),
batch_size=batchsize,
class_mode=None)