How to do it...

  1. 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
  1. 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
  1. 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} ...

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.