- The first step, as always, is including the necessary modules:
import tensorflow as tfimport numpy as npfrom tensorflow.examples.tutorials.mnist import input_dataimport matplotlib.pyplot as pltimport math%matplotlib inline
- Load the input data:
mnist = input_data.read_data_sets("MNIST_data/")trX, trY, teX, teY = mnist.train.images, mnist.train.labels, mnist.test.images, mnist.test.labels
- Define the network parameters. Here, we also calculate the spatial dimensions of the output of each max-pool layer; we need this information to upsample the image in the decoder network:
# Network Parametersh_in, w_in = 28, 28 # Image size height and widthk = 3 # Kernel sizep = 2 # pools = 2 # Strides in maxpoolfilters = {1:32,2:32,3:16} ...