GANS' (Generative Adversarial Networks) Flashcards
Cool uses for GANS
- create an imaginary photo of a bird based on a textual description 2. create an imaginary photo based on a hand drawing(Adobe) 3. Blueprints of buildings can be turned into finished buildings 4. Turn photo of face into a cartoon of a face(Facebook) 5. Turn photo of day scene into night scene(Nvidia) 6. Turn video of horse into a zebra(Berkley, CycleGan) 7. Simulated Training Set - Take 3D rendered images of eyes, turn into more realistic versions, then use these versions for training set to make predictions of where user is looking(Apple) 8. Imitation Learning
Basic Structure of GAN’s
- Model Inputs (Noise Vector Z and Real Images)
- Generator
- Discriminator
How to create the Generator Inputs in TF
How do you train a GAN
Show a lot of images and ask to create an image from same probability distribution. This is unsupervised learning.
Describe the training code for a GAN
- Build Models (Discriminator & Generator)
- Use Models to calculate Model Loss
- Optimize Model Loss
- Setup session, initalize global variables, start epochs
- Get real images and scale them
- Get random noise vector with appropriate distribution
- Run optimizers
Describe code to run optimizers
_ = sess.run(d_opt, feed_dict={input_real: batch_images, input_z: batch_z, lr: learning_rate})
_ = sess.run(g_opt, feed_dict={input_real: batch_images, input_z: batch_z, lr: learning_rate})
Describe How to create a Generator
- Take Input Noise Tensor and create a fully connected layer
- with tf.variable_scope(‘generator’, reuse= not is_train):
x1 = tf.layers.dense(z, 2*2*512)
- with tf.variable_scope(‘generator’, reuse= not is_train):
- Reshape the tensor to start a convolutional stack
- x1 = tf.reshape(x1, (-1, 2,2,512))
Describe what the output of the generator is and how it should be shaped
The output is an image which is handed to the discriminator. It must be the same size as the real images that are being fed to the discriminator outside of the generator
The input noise vector z, which is fed to the generator, where is this established?
- In the training code
- batch_z = np.random.uniform(-1, 1, size=(batch_size, z_dim)
- np.random.uniform parameters = (low, high, size/output shape)
- output shape is calculated by multiplying inputs provided and this is the amount of samples drawn. So it would be 64 * 100 is my example
- batch_size and z_dim are hyperparameters
- Uniform = Equally likely
Describe why we use a variable scope when creating a discriminator and generator