Tuesday, May 25, 2021

Generator for DCGAN

 Following is the code for generator for MNIST DCGAN 


import tensorflow as tf 
from tensorflow import keras 
from keras import layers 
import matplotlib.pyplot as plt 



img_height = 40 
img_width  = 80 

model = keras.models.Sequential()

model.add(layers.Dense(img_height/4 * img_width /4 * 256 , use_bias = False, 
                       input_shape = (100,)))
model.add(layers.BatchNormalization())
model.add(layers.LeakyReLU())

model.add(layers.Reshape(( int(img_height/4) , int(img_width/4) , 256)))


model.add(layers.Conv2DTranspose(128 , 5, strides = 1 , padding = "same" , 
                                 use_bias = False))
model.add(layers.BatchNormalization())
model.add(layers.LeakyReLU())


model.add(layers.Conv2DTranspose(64, 5, strides = 2 , use_bias = False, 
                                 padding = "same"))
model.add(layers.BatchNormalization())
model.add(layers.LeakyReLU())


model.add(layers.Conv2DTranspose(1, 5, strides = 2 , use_bias = False , 
                                 padding = "same"))


noise = tf.random.normal([1,100])
gen_image = model(noise , training = False)

plt.imshow(gen_image[0, :, :, 0])


No comments:

Post a Comment

Comparing features of LangGraph vs CrewAI

LangGraph Orchestration vs CrewAI Orchestration The following table compares LangGraph and CrewAI orchestration across their menta...