The steps to build a stacked autoencoder model in TensorFlow are as follows:
- First, define the hyper-parameters as follows:
learning_rate = 0.001n_epochs = 20batch_size = 100n_batches = int(mnist.train.num_examples/batch_size)
- 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
- 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])
- Add the number of neurons for encoder and decoder ...