Stacked autoencoder in TensorFlow

The steps  to build a stacked autoencoder model in TensorFlow are as follows:

  1. First, define the hyper-parameters as follows:
learning_rate = 0.001n_epochs = 20batch_size = 100n_batches = int(mnist.train.num_examples/batch_size)
  1. Define the number of inputs (that is, features) and outputs (that is, targets). The number of outputs will be the same as the number of inputs:
# number of pixels in the MNIST image as number of inputsn_inputs = 784n_outputs = n_inputs
  1. Define the placeholders for input and output images:
x = tf.placeholder(dtype=tf.float32, name="x", shape=[None, n_inputs])y = tf.placeholder(dtype=tf.float32, name="y", shape=[None, n_outputs])
  1. Add the number of neurons for encoder and decoder ...

Get Python: Advanced Guide to Artificial Intelligence now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.