In this project, you'll use generative adversarial networks to generate new images of faces.
You'll be using two datasets in this project:
Since the celebA dataset is complex and you're doing GANs in a project for the first time.
We want you to test your neural network on MNIST before CelebA.
Running the GANs on MNIST will allow you to see how well your model trains sooner.
If you're using FloydHub, set data_dir to "/input" and use the FloydHub data ID "R5KrjnANiKVhLWAkpXhNBe".
In [5]:
data_dir = '../GAN/data' # Aras: changed to my own path
# FloydHub - Use with data ID "R5KrjnANiKVhLWAkpXhNBe"
# data_dir = '/input'
"""
DON'T MODIFY ANYTHING IN THIS CELL
"""
import helper
helper.download_extract('mnist', data_dir)
helper.download_extract('celeba', data_dir)
As you're aware, the MNIST dataset contains images of handwritten digits.
You can view the first number of examples by changing show_n_images.
In [7]:
show_n_images = 25
"""
DON'T MODIFY ANYTHING IN THIS CELL
"""
%matplotlib inline
import os
from glob import glob
from matplotlib import pyplot
mnist_images = helper.get_batch(glob(os.path.join(data_dir, 'mnist/*.jpg'))[:show_n_images], 28, 28, 'L')
pyplot.imshow(helper.images_square_grid(mnist_images, 'L'), cmap='gray')
Out[7]:
In [8]:
mnist_images.shape
Out[8]:
The CelebFaces Attributes Dataset (CelebA) dataset contains over 200,000 celebrity images with annotations.
Since you're going to be generating faces, you won't need the annotations.
You can view the first number of examples by changing show_n_images.
In [9]:
show_n_images = 25
"""
DON'T MODIFY ANYTHING IN THIS CELL
"""
mnist_images = helper.get_batch(glob(os.path.join(data_dir, 'img_align_celeba/*.jpg'))[:show_n_images], 28, 28, 'RGB')
pyplot.imshow(helper.images_square_grid(mnist_images, 'RGB'))
Out[9]:
In [10]:
mnist_images.shape
Out[10]:
Since the project's main focus is on building the GANs, we'll preprocess the data for you.
The values of the MNIST and CelebA dataset will be in the range of -0.5 to 0.5 of 28x28 dimensional images.
The CelebA images will be cropped to remove parts of the image that don't include a face, then resized down to 28x28.
The MNIST images are black and white images with a single color channel while the CelebA images have 3 color channels (RGB color channel).
You'll build the components necessary to build a GANs by implementing the following functions below:
model_inputsdiscriminatorgeneratormodel_lossmodel_opttrainThis will check to make sure you have the correct version of TensorFlow and access to a GPU.
In [11]:
"""
DON'T MODIFY ANYTHING IN THIS CELL
"""
from distutils.version import LooseVersion
import warnings
import tensorflow as tf
# Check TensorFlow Version
assert LooseVersion(tf.__version__) >= LooseVersion('1.0'), 'Please use TensorFlow version 1.0 or newer. You are using {}'.format(tf.__version__)
print('TensorFlow Version: {}'.format(tf.__version__))
# Check for a GPU
if not tf.test.gpu_device_name():
warnings.warn('No GPU found. Please use a GPU to train your neural network.')
else:
print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
Implement the model_inputs function to create TF Placeholders for the Neural Network.
It should create the following placeholders:
image_width, image_height, and image_channels.z_dim.Return the placeholders in the following the tuple (tensor of real input images, tensor of z data).
In [12]:
import problem_unittests as tests
def model_inputs(image_width, image_height, image_channels, z_dim):
"""
Create the model inputs
:param image_width: The input image width --> 28
:param image_height: The input image height --> 28
:param image_channels: The number of image channels --> 3 RGB
:param z_dim: The dimension of Z --> n
:return: Tuple of (tensor of real input images, tensor of z data, learning rate)
"""
# TODO: Implement Function
# def model_inputs(real_dim, z_dim):
# real_size = (32,32,3)
real_dim = (image_height, image_width, image_channels) # hxwxc
input_real = tf.placeholder(dtype=tf.float32, shape=(None, *real_dim), name='input_real')
input_z = tf.placeholder(dtype=tf.float32, shape=(None, z_dim), name='input_z')
learning_rate = tf.placeholder(dtype=tf.float32, shape=None, name='learning_rate')
return input_real, input_z, learning_rate
"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
tests.test_model_inputs(model_inputs)
Implement discriminator to create a discriminator neural network that discriminates on images.
This function should be able to reuse the variabes in the neural network.
Use tf.variable_scope with a scope name of "discriminator" to allow the variables to be reused.
The function should return a tuple of (tensor output of the generator, tensor logits of the generator).
In [8]:
def conv2d_xavier(inputs, filters, kernel_size, strides, padding): #, trainable, reuse
out_conv = tf.layers.conv2d(inputs, filters, kernel_size, strides, padding,
data_format='channels_last', #strides=(1, 1), padding='valid',
dilation_rate=(1, 1), activation=None, use_bias=True,
kernel_initializer=tf.contrib.layers.xavier_initializer_conv2d(uniform=True, seed=None, dtype=tf.float32),
bias_initializer=tf.zeros_initializer(), kernel_regularizer=None, bias_regularizer=None,
activity_regularizer=None, trainable=True, name=None, reuse=None)
return out_conv
In [9]:
def conv2d_transpose_xavier(inputs, filters, kernel_size, strides, padding): #, trainable, reuse
out_conv_T = tf.layers.conv2d_transpose(inputs, filters, kernel_size, strides, padding,
data_format='channels_last', #strides=(1, 1), padding='valid', dilation_rate=(1, 1),
activation=None, use_bias=True,
kernel_initializer=tf.contrib.layers.xavier_initializer_conv2d(uniform=True, seed=None, dtype=tf.float32),
bias_initializer=tf.zeros_initializer(), kernel_regularizer=None, bias_regularizer=None,
activity_regularizer=None, trainable=True, name=None, reuse=None)
return out_conv_T
In [10]:
def dense_xavier(inputs, units):
out_dense = tf.layers.dense(inputs, units, activation=None, use_bias=True,
kernel_initializer=tf.contrib.layers.xavier_initializer(uniform=True, seed=None, dtype=tf.float32),
bias_initializer=tf.zeros_initializer(), kernel_regularizer=None, bias_regularizer=None,
activity_regularizer=None, trainable=True, name=None, reuse=None)
return out_dense
In [11]:
def discriminator(images, reuse=False):
"""
Create the discriminator network
:param image: Tensor of input image(s) --> txwxhxc --> tx28x28x3
:param reuse: Boolean if the weights should be reused
:return: Tuple of (tensor output of the discriminator, tensor logits of the discriminator)
"""
# TODO: Implement Function
# Implementation for DCGAN-svhn
# def discriminator(x, reuse=False, alpha=0.2):
alpha=0.2 # for leaky ReLU
with tf.variable_scope('discriminator', reuse=reuse):
# Input layer is 32x32x3 -> 28x28x3 in this case
# x1 = tf.layers.conv2d(inputs=images, filters=64, kernel_size=5, strides=2, padding='same')
x1 = conv2d_xavier(inputs=images, filters=64, kernel_size=5, strides=2, padding='same')
bn1 = tf.layers.batch_normalization(inputs=x1, training=True)
lrelu1 = tf.maximum(alpha * bn1, bn1)
# 16x16x64 -> 14x14x64 with stride 2 ans same image
# x2 = tf.layers.conv2d(inputs=lrelu1, filters=128, kernel_size=5, strides=2, padding='same')
x2 = conv2d_xavier(inputs=lrelu1, filters=128, kernel_size=5, strides=2, padding='same')
bn2 = tf.layers.batch_normalization(inputs=x2, training=True)
lrelu2 = tf.maximum(alpha * bn2, bn2)
# 8x8x128 -> 7x7x128 with stride 2
# x3 = tf.layers.conv2d(inputs=lrelu2, filters=256, kernel_size=7, strides=1, padding='same')
x3 = conv2d_xavier(inputs=lrelu2, filters=256, kernel_size=7, strides=1, padding='same')
bn3 = tf.layers.batch_normalization(inputs=x3, training=True)
lrelu3 = tf.maximum(alpha * bn3, bn3)
# 4x4x256 -> 7x7x256 with stride 1 so NO change
# Flatten it/ flattening layer
# 1st way
# flat = tf.reshape(relu3, (-1, 4*4*256))
# 2nd way to flattening
# Feedback tip
# Excellent work.
# You can flatten a layer with tf.contrib.layers.flatten()
# check out: https://www.tensorflow.org/api_docs/python/tf/contrib/layers/flatten
# flat = tf.contrib.layers.flatten(inputs=relu3)
flat = tf.reshape(tensor=lrelu3, shape=(-1, 7*7*256), name=None)
# # How to add dropout and WHERE to add the dropout layer
# # Dense Layer
# pool2_flat = tf.reshape(pool2, [-1, 7 * 7 * 64])
# dense = tf.layers.dense(inputs=pool2_flat, units=1024, activation=tf.nn.relu)
# dropout = tf.layers.dropout(
# inputs=dense, rate=0.4, training=mode == learn.ModeKeys.TRAIN)
# # Logits Layer
# logits = tf.layers.dense(inputs=dropout, units=10)
flat = tf.layers.dropout(inputs=flat, rate=0.5, training=True)
# logits = tf.layers.dense(inputs=flat, units=1) # 1 output unit for 1, 0 or real/fake as the binary output
logits = dense_xavier(inputs=flat, units=1) # 1 output unit for 1, 0 or real/fake as the binary output
out = tf.sigmoid(x=logits) # prob/confidence for one output/unit classification
return out, logits
# # 2nd feedback tips
# Most of the suggestions are same for both Generator and Discriminator.
# Discriminator
# 1- Using dropout in discriminator so that it is less prone to learning the data distribution.
# 2- Use custom weight initialization. Xavier init is proposed to work best when working with GANs.
# Generator
# 1- Try setting leak for leaky_relu a bit lower. Did you tried 0.1 ?
# 2- Try decreasing the width of layers from 512 -> 64. In context of GANs,
# a sharp decline in number of filters for Generator helps produce better results.
"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
tests.test_discriminator(discriminator, tf)
Implement generator to generate an image using z.
This function should be able to reuse the variabes in the neural network.
Use tf.variable_scope with a scope name of "generator" to allow the variables to be reused.
The function should return the generated 28 x 28 x out_channel_dim images.
In [12]:
def generator(z, out_channel_dim, is_train=True):
"""
Create the generator network
:param z: Input z
:param out_channel_dim: The number of channels in the output image
:param is_train: Boolean if generator is being used for training
:return: The tensor output of the generator
"""
# TODO: Implement Function
# def generator(z, output_dim, reuse=False, alpha=0.2, training=True):
alpha=0.2
reuse = not is_train
with tf.variable_scope('generator', reuse=reuse):
# First fully connected layer
# x1 = tf.layers.dense(z, 4*4*512)
# z is z_1x100=mat_txn, t/time/bacth, n/space/num_dim
# x1 = tf.layers.dense(inputs=z, units=7*7*512) # start from the last layer of discriminator/classifier/recognizer/perdictor
x1 = dense_xavier(inputs=z, units=7*7*512) # start from the last layer of discriminator/classifier/recognizer/perdictor
# x1_1x7*7*512 -> 1x7x7x512
# Reshape it to start the convolutional stack
x1 = tf.reshape(tensor=x1, shape=(-1, 7, 7, 512), name=None)
bn1 = tf.layers.batch_normalization(inputs=x1, training=is_train)
lrelu1 = tf.maximum(alpha * bn1, bn1)
# 4x4x512 now -> tx7x7x512, t=1 means one sample/record/image in each fwd/bwd prop/pass/path/route
# x2 = tf.layers.conv2d_transpose(inputs=lrelu1, filters=256, kernel_size=7, strides=1, padding='same')
x2 = conv2d_transpose_xavier(inputs=lrelu1, filters=256, kernel_size=7, strides=1, padding='same')
bn2 = tf.layers.batch_normalization(inputs=x2, training=is_train)
lrelu2 = tf.maximum(alpha * bn2, bn2)
# 8x8x256 now -> 7x7x256 with stride=1
# x3 = tf.layers.conv2d_transpose(inputs=lrelu2, filters=128, kernel_size=5, strides=2, padding='same')
x3 = conv2d_transpose_xavier(inputs=lrelu2, filters=128, kernel_size=5, strides=2, padding='same')
bn3 = tf.layers.batch_normalization(inputs=x3, training=is_train)
lrelu3 = tf.maximum(alpha * bn3, bn3)
# 16x16x128 now -> tx14x14x128
# # How to add dropout and WHERE to add the dropout layer
# # Dense Layer
# pool2_flat = tf.reshape(pool2, [-1, 7 * 7 * 64])
# dense = tf.layers.dense(inputs=pool2_flat, units=1024, activation=tf.nn.relu)
# dropout = tf.layers.dropout(
# inputs=dense, rate=0.4, training=mode == learn.ModeKeys.TRAIN)
# # Logits Layer
# logits = tf.layers.dense(inputs=dropout, units=10)
lrelu3 = tf.layers.dropout(inputs=lrelu3, rate=0.5, training=is_train)
# Output layer
# logits = tf.layers.conv2d_transpose(inputs=lrelu3, filters=out_channel_dim, kernel_size=5, strides=2, padding='same')
logits = conv2d_transpose_xavier(inputs=lrelu3, filters=out_channel_dim, kernel_size=5, strides=2, padding='same')
# 32x32x3 now -> tx28x28x3 the actual image size
# prediction and regression -1, +1
out = tf.tanh(logits)
return out
"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
tests.test_generator(generator, tf)
In [13]:
import numpy as np
def model_loss(input_real, input_z, out_channel_dim):
"""
Get the loss for the discriminator and generator
:param input_real: Images from the real dataset
:param input_z: Z input
:param out_channel_dim: The number of channels in the output image
:return: A tuple of (discriminator loss, generator loss)
"""
# TODO: Implement Function
g_model = generator(z=input_z, out_channel_dim=out_channel_dim) # alpha is included inside
d_model_real, d_logits_real = discriminator(images=input_real) # alpha included
d_model_fake, d_logits_fake = discriminator(images=g_model, reuse=True) # alpha included
# Label smoothing to add noise to the labels for the fake and real labels
d_loss_real = tf.reduce_mean(input_tensor=
# tf.nn.sigmoid_cross_entropy_with_logits(logits=d_logits_real, labels=tf.ones_like(d_model_real)))
tf.nn.sigmoid_cross_entropy_with_logits(logits=d_logits_real, # should be around 1.0
labels=tf.ones_like(d_model_real) * np.random.uniform(low=0.7, high=1.2)))
d_loss_fake = tf.reduce_mean(input_tensor=
# tf.nn.sigmoid_cross_entropy_with_logits(logits=d_logits_fake, labels=tf.zeros_like(d_model_fake)))
tf.nn.sigmoid_cross_entropy_with_logits(logits=d_logits_fake, # should close to 0.0 as noise
labels=tf.zeros_like(d_model_fake) + np.random.uniform(low=0.0, high=0.3)))
g_loss = tf.reduce_mean(input_tensor=
tf.nn.sigmoid_cross_entropy_with_logits(logits=d_logits_fake, labels=tf.ones_like(d_model_fake)))
d_loss = d_loss_real + d_loss_fake
return d_loss, g_loss
# 2nd feedback hints/tips
# The function model_loss is implemented correctly.
# Perfect.
# Now that was the trickiest part (and my personal favorite in GAN :)
# Tips
# 1- Use Label Smoothing for Discriminator loss, will help it generalize better.
# If you have two target labels: Real=1 and Fake=0, then for each incoming sample,
# if it is real, then replace the label with a random number between 0.7 and 1.2,
# and if it is a fake sample, replace it with 0.0 and 0.3 (for example).
# A simple change like labels = tf.ones_like(d_logits_real) * np.random.uniform(0.7, 1.2) will help with
# the training process.
# This is known as label smoothing, typically used with classifiers to improve performance.
"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
tests.test_model_loss(model_loss)
Implement model_opt to create the optimization operations for the GANs.
Use tf.trainable_variables to get all the trainable variables. Filter the variables with names that are in the discriminator and generator scope names.
The function should return a tuple of (discriminator training operation, generator training operation).
In [14]:
def model_opt(d_loss, g_loss, learning_rate, beta1):
"""
Get optimization operations
:param d_loss: Discriminator loss Tensor
:param g_loss: Generator loss Tensor
:param learning_rate: Learning Rate Placeholder
:param beta1: The exponential decay rate for the 1st moment in the optimizer
:return: A tuple of (discriminator training operation, generator training operation)
"""
# TODO: Implement Function
# Get weights and bias to update
t_vars = tf.trainable_variables()
d_vars = [var for var in t_vars if var.name.startswith('discriminator')]
g_vars = [var for var in t_vars if var.name.startswith('generator')]
# Optimize
d_train_opt = tf.train.AdamOptimizer(learning_rate, beta1=beta1).minimize(d_loss, var_list=d_vars)
g_train_opt = tf.train.AdamOptimizer(learning_rate, beta1=beta1).minimize(g_loss, var_list=g_vars)
return d_train_opt, g_train_opt
"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
tests.test_model_opt(model_opt, tf)
In [15]:
"""
DON'T MODIFY ANYTHING IN THIS CELL
"""
import numpy as np
def show_generator_output(sess, n_images, input_z, out_channel_dim, image_mode):
"""
Show example output for the generator
:param sess: TensorFlow session
:param n_images: Number of Images to display
:param input_z: Input Z Tensor
:param out_channel_dim: The number of channels in the output image
:param image_mode: The mode to use for images ("RGB" or "L")
"""
cmap = None if image_mode == 'RGB' else 'gray'
z_dim = input_z.get_shape().as_list()[-1]
example_z = np.random.uniform(-1, 1, size=[n_images, z_dim])
samples = sess.run(
generator(input_z, out_channel_dim, False),
feed_dict={input_z: example_z})
images_grid = helper.images_square_grid(samples, image_mode)
pyplot.imshow(images_grid, cmap=cmap)
pyplot.show()
Implement train to build and train the GANs.
Use the following functions you implemented:
model_inputs(image_width, image_height, image_channels, z_dim)model_loss(input_real, input_z, out_channel_dim)model_opt(d_loss, g_loss, learning_rate, beta1)Use the show_generator_output to show generator output while you train.
Running show_generator_output for every batch will drastically increase training time and increase the size of the notebook.
It's recommended to print the generator output every 100 batches.
In [16]:
def train(epoch_count, batch_size, z_dim, learning_rate, beta1, get_batches, data_shape, data_image_mode):
"""
Train the GAN
:param epoch_count: Number of epochs
:param batch_size: Batch Size
:param z_dim: Z dimension
:param learning_rate: Learning Rate
:param beta1: The exponential decay rate for the 1st moment in the optimizer
:param get_batches: Function to get batches
:param data_shape: Shape of the data
:param data_image_mode: The image mode to use for images ("RGB" or "L")
"""
# TODO: Build Model
# data_shape, e.g. mnist_dataset.shape == txhxwxc == shape== 0, 1, 2, 3
input_real, input_z, lr = model_inputs(image_width=data_shape[1],
image_height=data_shape[2],
image_channels=data_shape[3],
z_dim=z_dim)
# 1st and 2nd Feedback tip
# Great success has been shown if you wrap g_train_opt with
# tf.control_dependencies(tf.get_collection(tf.GraphKeys.UPDATE_OPS)):
# More details can be found here: http://ruishu.io/2016/12/27/batchnorm/
# tf.control_dependencies() is used in the batch normalization lessons,
# and is necessary to get the normalization layers created
# with tf.layers.batch_normalization to update their population statistics,
# which we need when performing inference.
update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
with tf.control_dependencies(update_ops):
# Ensures that we execute the update_ops before performing the train_step
# train_step = tf.train.GradientDescentOptimizer(0.01).minimize(loss)
d_loss, g_loss = model_loss(input_real=input_real, input_z=input_z, out_channel_dim=data_shape[3])
d_opt, g_opt = model_opt(d_loss=d_loss, g_loss=g_loss, learning_rate=lr, beta1=beta1)
steps = 0 # for printing the generator output every 100 batches
show_every = 100 # show the generated images
print_every = 10 # printing out the loss for g and d
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for epoch_i in range(epoch_count):
# batches_txn: t== number of minibatches,
# n== batch_size/ number of smaples/records/images in each minibatch
for batch_images in get_batches(batch_size):
# TODO: Train Model
# 1st and 2nd Feedback tip
# Since the images are scaled to -0.5:0.5 and we are using tanh in the generator,
# you will likely see improved performance
# if you perform batch_images *= 2 in order to scale it to -1:1
batch_images *= 2
# for x, y in dataset.batches(batch_size):
steps += 1
# Sample random noise for G
batch_z = np.random.uniform(-1, 1, size=(batch_size, z_dim)) # txn: t==batch_size, n==z_dim
# 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_z: batch_z, lr: learning_rate}) # 1st time
# 1st feedback tip
# Another tip, while not required,
# you can try to run the optimization for the generator twice --> g_opt
# to make sure that the discriminator loss does not go to zero.
_ = sess.run(g_opt, feed_dict={input_z: batch_z, lr: learning_rate}) # 2nd time
# Feedback tip: 1st one
# You're close!
# You may need to tune your discriminator and generator a bit,
# but first follow my advice below.
# Additionally, you should print the loss after each batch for both of your networks,
# that will give you some hints on what you need to change to get good output.
# For example, if your discriminator loss goes to zero,
# you know you may need to make your generator stronger, or
# run the optimizer for it again for each batch.
if steps % print_every == 0:
# At the end of each epoch, get the losses and print them out
train_loss_d = d_loss.eval(feed_dict={input_z: batch_z, input_real: batch_images, lr: learning_rate})
train_loss_g = g_loss.eval(feed_dict={input_z: batch_z, lr: learning_rate})
print("Epoch {}/{}...".format(epoch_i+1, epoch_count),
"stpes: {:.4f}...".format(steps),
"Discriminator Loss: {:.4f}...".format(train_loss_d),
"Generator Loss: {:.4f}".format(train_loss_g))
# show generator output every 100 minibatches training in each epoch
# one epoch, t minibatches, each minibatch for training/updating the params in gnet and dnet
if steps % show_every == 0:
show_n_images = 4 # nrows=5 , ncols=5, nrows*ncols=25
show_generator_output(sess=sess, n_images=show_n_images, input_z=input_z,
out_channel_dim=data_shape[3], image_mode=data_image_mode)
In [17]:
# Hyperparameters for both dataset GANs training, valid, and testing
batch_size = 128
z_dim = 100
learning_rate = 0.0002 # 2/128 = 1/64
beta1 = 0.5
# The hyperparameters in DCGAN SVHN impl recom.
# real_size = (32,32,3) -> (28, 28, 3) in this case for both mnist and celebA datasets
# z_size = 100
# learning_rate = 0.0002
# batch_size = 128
# epochs = 25
# alpha = 0.2
# beta1 = 0.5
# 2nd feedback comments/hints/tips
# Given your network architecture, the choice of hyper-parameter are reasonable.
# Tips
# 1- You selected a good value for beta1.
# Here's a good post explaining the importance of beta values and which value might be empirically better.
# Also try lowering it even further, ~0.1 might even produce better results.
# 2- An important point to note is, batch size and learning rate are linked.
# If the batch size is too small then the gradients will become more unstable and would need to
# reduce the learning rate.
# Batch size used is on higher side. Try setting a value around 32/64.
# We know that larger batch sizes might speed up the training but can degrade the quality of the model at the same time.
# This link might help you.
# You can also read about this in the hyperparameters module in your classroom.
In [18]:
"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
epochs = 2
mnist_dataset = helper.Dataset('mnist', glob(os.path.join(data_dir, 'mnist/*.jpg')))
with tf.Graph().as_default():
train(epochs, batch_size, z_dim, learning_rate, beta1, mnist_dataset.get_batches,
mnist_dataset.shape, mnist_dataset.image_mode)
In [ ]:
"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
epochs = 1
celeba_dataset = helper.Dataset('celeba', glob(os.path.join(data_dir, 'img_align_celeba/*.jpg')))
with tf.Graph().as_default():
train(epochs, batch_size, z_dim, learning_rate, beta1, celeba_dataset.get_batches,
celeba_dataset.shape, celeba_dataset.image_mode)
When submitting this project, make sure to run all the cells before saving the notebook. Save the notebook file as "dlnd_face_generation.ipynb" and save it as a HTML file under "File" -> "Download as". Include the "helper.py" and "problem_unittests.py" files in your submission.