How to do it...

We proceed with the recipe as follows:

  1. Clone the code from github:
git clone https://github.com/TengdaHan/GAN-TensorFlow
  1. Define a Xavier initializer as defined in the paper Understanding the difficulty of training deep feedforward neural networks (2009) by Xavier Glorot, Yoshua Bengio. The initializers are proven to allow better convergence for GANs:
def xavier_init(size):  in_dim = size[0]  xavier_stddev = 1. / tf.sqrt(in_dim / 2.)  # return tf.random_normal(shape=size, stddev=xavier_stddev)  return xavier_stddev
  1. Define a convolutional operation for the given input x, weight w, bias b, and given stride. Our code uses the standard tf.nn.conv2d(...) module. Note that we use 'SAME' padding, as defined in Chapter 4:
def conv(x, ...

Get TensorFlow 1.x Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.