In [1]:
import tensorflow as tf
from keras.datasets import mnist
from keras.utils import np_utils
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['image.cmap'] = 'gray'
%matplotlib inline


Using TensorFlow backend.

In [2]:
from IPython.display import clear_output, Image, display, HTML

# Helper functions for TF Graph visualization

def strip_consts(graph_def, max_const_size=32):
    """Strip large constant values from graph_def."""
    strip_def = tf.GraphDef()
    for n0 in graph_def.node:
        n = strip_def.node.add() 
        n.MergeFrom(n0)
        if n.op == 'Const':
            tensor = n.attr['value'].tensor
            size = len(tensor.tensor_content)
            if size > max_const_size:
                tensor.tensor_content = tf.compat.as_bytes("<stripped %d bytes>"%size)
    return strip_def
  
def show_graph(graph_def, max_const_size=32):
    """Visualize TensorFlow graph."""
    if hasattr(graph_def, 'as_graph_def'):
        graph_def = graph_def.as_graph_def()
    strip_def = strip_consts(graph_def, max_const_size=max_const_size)
    code = """
        <script>
          function load() {{
            document.getElementById("{id}").pbtxt = {data};
          }}
        </script>
        <link rel="import" href="https://tensorboard.appspot.com/tf-graph-basic.build.html" onload=load()>
        <div style="height:600px">
          <tf-graph-basic id="{id}"></tf-graph-basic>
        </div>
    """.format(data=repr(str(strip_def)), id='graph'+str(np.random.rand()))
  
    iframe = """
        <iframe seamless style="width:800px;height:620px;border:0" srcdoc="{}"></iframe>
    """.format(code.replace('"', '&quot;'))
    display(HTML(iframe))

In [6]:
# Restore model.
sess = tf.Session()    
#First let's load meta graph and restore weights
saver = tf.train.import_meta_graph('tf_mnist_model_layers/tf_mnist_model.ckpt.meta')
saver.restore(sess,tf.train.latest_checkpoint('tf_mnist_model_layers/'))
show_graph(sess.graph)


INFO:tensorflow:Restoring parameters from tf_mnist_model_layers/tf_mnist_model.ckpt

Load the data


In [8]:
dataset = mnist.load_data()
train_data = dataset[0][0] / 255
train_data = train_data[..., np.newaxis].astype('float32')
train_labels = np_utils.to_categorical(dataset[0][1]).astype('float32')
test_data = dataset[1][0] / 255
test_data = test_data[..., np.newaxis].astype('float32')
test_labels = np_utils.to_categorical(dataset[1][1]).astype('float32')
plt.imshow(train_data[0, ..., 0])


Out[8]:
<matplotlib.image.AxesImage at 0x7f47a1ebc8d0>

In order to do infernce one has to know which tensor holds the relevant predictions, at least if one is using the plain graph and not the estimator API. One also has to recover the input tensor to feed the data to.


In [4]:
sess.graph.get_operations()


Out[4]:
[<tf.Operation 'Placeholder' type=Placeholder>,
 <tf.Operation 'Placeholder_1' type=Placeholder>,
 <tf.Operation 'training/input' type=Const>,
 <tf.Operation 'training' type=PlaceholderWithDefault>,
 <tf.Operation 'conv2d_1/kernel/Initializer/truncated_normal/shape' type=Const>,
 <tf.Operation 'conv2d_1/kernel/Initializer/truncated_normal/mean' type=Const>,
 <tf.Operation 'conv2d_1/kernel/Initializer/truncated_normal/stddev' type=Const>,
 <tf.Operation 'conv2d_1/kernel/Initializer/truncated_normal/TruncatedNormal' type=TruncatedNormal>,
 <tf.Operation 'conv2d_1/kernel/Initializer/truncated_normal/mul' type=Mul>,
 <tf.Operation 'conv2d_1/kernel/Initializer/truncated_normal' type=Add>,
 <tf.Operation 'conv2d_1/kernel' type=VariableV2>,
 <tf.Operation 'conv2d_1/kernel/Assign' type=Assign>,
 <tf.Operation 'conv2d_1/kernel/read' type=Identity>,
 <tf.Operation 'conv2d_1/bias/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_1/bias' type=VariableV2>,
 <tf.Operation 'conv2d_1/bias/Assign' type=Assign>,
 <tf.Operation 'conv2d_1/bias/read' type=Identity>,
 <tf.Operation 'conv2d_1/convolution/Shape' type=Const>,
 <tf.Operation 'conv2d_1/convolution/dilation_rate' type=Const>,
 <tf.Operation 'conv2d_1/convolution' type=Conv2D>,
 <tf.Operation 'conv2d_1/BiasAdd' type=BiasAdd>,
 <tf.Operation 'conv2d_1/Relu' type=Relu>,
 <tf.Operation 'max_pooling2d_1/MaxPool' type=MaxPool>,
 <tf.Operation 'conv2d_2/kernel/Initializer/truncated_normal/shape' type=Const>,
 <tf.Operation 'conv2d_2/kernel/Initializer/truncated_normal/mean' type=Const>,
 <tf.Operation 'conv2d_2/kernel/Initializer/truncated_normal/stddev' type=Const>,
 <tf.Operation 'conv2d_2/kernel/Initializer/truncated_normal/TruncatedNormal' type=TruncatedNormal>,
 <tf.Operation 'conv2d_2/kernel/Initializer/truncated_normal/mul' type=Mul>,
 <tf.Operation 'conv2d_2/kernel/Initializer/truncated_normal' type=Add>,
 <tf.Operation 'conv2d_2/kernel' type=VariableV2>,
 <tf.Operation 'conv2d_2/kernel/Assign' type=Assign>,
 <tf.Operation 'conv2d_2/kernel/read' type=Identity>,
 <tf.Operation 'conv2d_2/bias/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_2/bias' type=VariableV2>,
 <tf.Operation 'conv2d_2/bias/Assign' type=Assign>,
 <tf.Operation 'conv2d_2/bias/read' type=Identity>,
 <tf.Operation 'conv2d_2/convolution/Shape' type=Const>,
 <tf.Operation 'conv2d_2/convolution/dilation_rate' type=Const>,
 <tf.Operation 'conv2d_2/convolution' type=Conv2D>,
 <tf.Operation 'conv2d_2/BiasAdd' type=BiasAdd>,
 <tf.Operation 'conv2d_2/Relu' type=Relu>,
 <tf.Operation 'dropout_1/cond/Switch' type=Switch>,
 <tf.Operation 'dropout_1/cond/switch_t' type=Identity>,
 <tf.Operation 'dropout_1/cond/switch_f' type=Identity>,
 <tf.Operation 'dropout_1/cond/pred_id' type=Identity>,
 <tf.Operation 'dropout_1/cond/dropout/keep_prob' type=Const>,
 <tf.Operation 'dropout_1/cond/dropout/Shape/Switch' type=Switch>,
 <tf.Operation 'dropout_1/cond/dropout/Shape' type=Shape>,
 <tf.Operation 'dropout_1/cond/dropout/random_uniform/min' type=Const>,
 <tf.Operation 'dropout_1/cond/dropout/random_uniform/max' type=Const>,
 <tf.Operation 'dropout_1/cond/dropout/random_uniform/RandomUniform' type=RandomUniform>,
 <tf.Operation 'dropout_1/cond/dropout/random_uniform/sub' type=Sub>,
 <tf.Operation 'dropout_1/cond/dropout/random_uniform/mul' type=Mul>,
 <tf.Operation 'dropout_1/cond/dropout/random_uniform' type=Add>,
 <tf.Operation 'dropout_1/cond/dropout/add' type=Add>,
 <tf.Operation 'dropout_1/cond/dropout/Floor' type=Floor>,
 <tf.Operation 'dropout_1/cond/dropout/div' type=RealDiv>,
 <tf.Operation 'dropout_1/cond/dropout/mul' type=Mul>,
 <tf.Operation 'dropout_1/cond/Identity/Switch' type=Switch>,
 <tf.Operation 'dropout_1/cond/Identity' type=Identity>,
 <tf.Operation 'dropout_1/cond/Merge' type=Merge>,
 <tf.Operation 'Flatten/Shape' type=Shape>,
 <tf.Operation 'Flatten/Slice/begin' type=Const>,
 <tf.Operation 'Flatten/Slice/size' type=Const>,
 <tf.Operation 'Flatten/Slice' type=Slice>,
 <tf.Operation 'Flatten/Slice_1/begin' type=Const>,
 <tf.Operation 'Flatten/Slice_1/size' type=Const>,
 <tf.Operation 'Flatten/Slice_1' type=Slice>,
 <tf.Operation 'Flatten/Const' type=Const>,
 <tf.Operation 'Flatten/Prod' type=Prod>,
 <tf.Operation 'Flatten/ExpandDims/dim' type=Const>,
 <tf.Operation 'Flatten/ExpandDims' type=ExpandDims>,
 <tf.Operation 'Flatten/concat/axis' type=Const>,
 <tf.Operation 'Flatten/concat' type=ConcatV2>,
 <tf.Operation 'Flatten/Reshape' type=Reshape>,
 <tf.Operation 'dense_1/kernel/Initializer/random_uniform/shape' type=Const>,
 <tf.Operation 'dense_1/kernel/Initializer/random_uniform/min' type=Const>,
 <tf.Operation 'dense_1/kernel/Initializer/random_uniform/max' type=Const>,
 <tf.Operation 'dense_1/kernel/Initializer/random_uniform/RandomUniform' type=RandomUniform>,
 <tf.Operation 'dense_1/kernel/Initializer/random_uniform/sub' type=Sub>,
 <tf.Operation 'dense_1/kernel/Initializer/random_uniform/mul' type=Mul>,
 <tf.Operation 'dense_1/kernel/Initializer/random_uniform' type=Add>,
 <tf.Operation 'dense_1/kernel' type=VariableV2>,
 <tf.Operation 'dense_1/kernel/Assign' type=Assign>,
 <tf.Operation 'dense_1/kernel/read' type=Identity>,
 <tf.Operation 'dense_1/bias/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_1/bias' type=VariableV2>,
 <tf.Operation 'dense_1/bias/Assign' type=Assign>,
 <tf.Operation 'dense_1/bias/read' type=Identity>,
 <tf.Operation 'dense_1/MatMul' type=MatMul>,
 <tf.Operation 'dense_1/BiasAdd' type=BiasAdd>,
 <tf.Operation 'dense_1/Relu' type=Relu>,
 <tf.Operation 'dropout_2/cond/Switch' type=Switch>,
 <tf.Operation 'dropout_2/cond/switch_t' type=Identity>,
 <tf.Operation 'dropout_2/cond/switch_f' type=Identity>,
 <tf.Operation 'dropout_2/cond/pred_id' type=Identity>,
 <tf.Operation 'dropout_2/cond/dropout/keep_prob' type=Const>,
 <tf.Operation 'dropout_2/cond/dropout/Shape/Switch' type=Switch>,
 <tf.Operation 'dropout_2/cond/dropout/Shape' type=Shape>,
 <tf.Operation 'dropout_2/cond/dropout/random_uniform/min' type=Const>,
 <tf.Operation 'dropout_2/cond/dropout/random_uniform/max' type=Const>,
 <tf.Operation 'dropout_2/cond/dropout/random_uniform/RandomUniform' type=RandomUniform>,
 <tf.Operation 'dropout_2/cond/dropout/random_uniform/sub' type=Sub>,
 <tf.Operation 'dropout_2/cond/dropout/random_uniform/mul' type=Mul>,
 <tf.Operation 'dropout_2/cond/dropout/random_uniform' type=Add>,
 <tf.Operation 'dropout_2/cond/dropout/add' type=Add>,
 <tf.Operation 'dropout_2/cond/dropout/Floor' type=Floor>,
 <tf.Operation 'dropout_2/cond/dropout/div' type=RealDiv>,
 <tf.Operation 'dropout_2/cond/dropout/mul' type=Mul>,
 <tf.Operation 'dropout_2/cond/Identity/Switch' type=Switch>,
 <tf.Operation 'dropout_2/cond/Identity' type=Identity>,
 <tf.Operation 'dropout_2/cond/Merge' type=Merge>,
 <tf.Operation 'dense_2/kernel/Initializer/random_uniform/shape' type=Const>,
 <tf.Operation 'dense_2/kernel/Initializer/random_uniform/min' type=Const>,
 <tf.Operation 'dense_2/kernel/Initializer/random_uniform/max' type=Const>,
 <tf.Operation 'dense_2/kernel/Initializer/random_uniform/RandomUniform' type=RandomUniform>,
 <tf.Operation 'dense_2/kernel/Initializer/random_uniform/sub' type=Sub>,
 <tf.Operation 'dense_2/kernel/Initializer/random_uniform/mul' type=Mul>,
 <tf.Operation 'dense_2/kernel/Initializer/random_uniform' type=Add>,
 <tf.Operation 'dense_2/kernel' type=VariableV2>,
 <tf.Operation 'dense_2/kernel/Assign' type=Assign>,
 <tf.Operation 'dense_2/kernel/read' type=Identity>,
 <tf.Operation 'dense_2/bias/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_2/bias' type=VariableV2>,
 <tf.Operation 'dense_2/bias/Assign' type=Assign>,
 <tf.Operation 'dense_2/bias/read' type=Identity>,
 <tf.Operation 'dense_2/MatMul' type=MatMul>,
 <tf.Operation 'dense_2/BiasAdd' type=BiasAdd>,
 <tf.Operation 'loss/Rank' type=Const>,
 <tf.Operation 'loss/Shape' type=Shape>,
 <tf.Operation 'loss/Rank_1' type=Const>,
 <tf.Operation 'loss/Shape_1' type=Shape>,
 <tf.Operation 'loss/Sub/y' type=Const>,
 <tf.Operation 'loss/Sub' type=Sub>,
 <tf.Operation 'loss/Slice/begin' type=Pack>,
 <tf.Operation 'loss/Slice/size' type=Const>,
 <tf.Operation 'loss/Slice' type=Slice>,
 <tf.Operation 'loss/concat/values_0' type=Const>,
 <tf.Operation 'loss/concat/axis' type=Const>,
 <tf.Operation 'loss/concat' type=ConcatV2>,
 <tf.Operation 'loss/Reshape' type=Reshape>,
 <tf.Operation 'loss/Rank_2' type=Const>,
 <tf.Operation 'loss/Shape_2' type=Shape>,
 <tf.Operation 'loss/Sub_1/y' type=Const>,
 <tf.Operation 'loss/Sub_1' type=Sub>,
 <tf.Operation 'loss/Slice_1/begin' type=Pack>,
 <tf.Operation 'loss/Slice_1/size' type=Const>,
 <tf.Operation 'loss/Slice_1' type=Slice>,
 <tf.Operation 'loss/concat_1/values_0' type=Const>,
 <tf.Operation 'loss/concat_1/axis' type=Const>,
 <tf.Operation 'loss/concat_1' type=ConcatV2>,
 <tf.Operation 'loss/Reshape_1' type=Reshape>,
 <tf.Operation 'loss/SoftmaxCrossEntropyWithLogits' type=SoftmaxCrossEntropyWithLogits>,
 <tf.Operation 'loss/Sub_2/y' type=Const>,
 <tf.Operation 'loss/Sub_2' type=Sub>,
 <tf.Operation 'loss/Slice_2/begin' type=Const>,
 <tf.Operation 'loss/Slice_2/size' type=Pack>,
 <tf.Operation 'loss/Slice_2' type=Slice>,
 <tf.Operation 'loss/Reshape_2' type=Reshape>,
 <tf.Operation 'loss/Const' type=Const>,
 <tf.Operation 'loss/Mean' type=Mean>,
 <tf.Operation 'gradients/Shape' type=Const>,
 <tf.Operation 'gradients/Const' type=Const>,
 <tf.Operation 'gradients/Fill' type=Fill>,
 <tf.Operation 'gradients/loss/Mean_grad/Reshape/shape' type=Const>,
 <tf.Operation 'gradients/loss/Mean_grad/Reshape' type=Reshape>,
 <tf.Operation 'gradients/loss/Mean_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/loss/Mean_grad/Tile' type=Tile>,
 <tf.Operation 'gradients/loss/Mean_grad/Shape_1' type=Shape>,
 <tf.Operation 'gradients/loss/Mean_grad/Shape_2' type=Const>,
 <tf.Operation 'gradients/loss/Mean_grad/Const' type=Const>,
 <tf.Operation 'gradients/loss/Mean_grad/Prod' type=Prod>,
 <tf.Operation 'gradients/loss/Mean_grad/Const_1' type=Const>,
 <tf.Operation 'gradients/loss/Mean_grad/Prod_1' type=Prod>,
 <tf.Operation 'gradients/loss/Mean_grad/Maximum/y' type=Const>,
 <tf.Operation 'gradients/loss/Mean_grad/Maximum' type=Maximum>,
 <tf.Operation 'gradients/loss/Mean_grad/floordiv' type=FloorDiv>,
 <tf.Operation 'gradients/loss/Mean_grad/Cast' type=Cast>,
 <tf.Operation 'gradients/loss/Mean_grad/truediv' type=RealDiv>,
 <tf.Operation 'gradients/loss/Reshape_2_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/loss/Reshape_2_grad/Reshape' type=Reshape>,
 <tf.Operation 'gradients/zeros_like' type=ZerosLike>,
 <tf.Operation 'gradients/loss/SoftmaxCrossEntropyWithLogits_grad/ExpandDims/dim' type=Const>,
 <tf.Operation 'gradients/loss/SoftmaxCrossEntropyWithLogits_grad/ExpandDims' type=ExpandDims>,
 <tf.Operation 'gradients/loss/SoftmaxCrossEntropyWithLogits_grad/mul' type=Mul>,
 <tf.Operation 'gradients/loss/Reshape_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/loss/Reshape_grad/Reshape' type=Reshape>,
 <tf.Operation 'gradients/dense_2/BiasAdd_grad/BiasAddGrad' type=BiasAddGrad>,
 <tf.Operation 'gradients/dense_2/BiasAdd_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dense_2/BiasAdd_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dense_2/BiasAdd_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/dense_2/MatMul_grad/MatMul' type=MatMul>,
 <tf.Operation 'gradients/dense_2/MatMul_grad/MatMul_1' type=MatMul>,
 <tf.Operation 'gradients/dense_2/MatMul_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dense_2/MatMul_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dense_2/MatMul_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/dropout_2/cond/Merge_grad/cond_grad' type=Switch>,
 <tf.Operation 'gradients/dropout_2/cond/Merge_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dropout_2/cond/Merge_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dropout_2/cond/Merge_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/Shape_1' type=Shape>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/BroadcastGradientArgs' type=BroadcastGradientArgs>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/mul' type=Mul>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/Sum' type=Sum>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/Reshape' type=Reshape>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/mul_1' type=Mul>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/Sum_1' type=Sum>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/Reshape_1' type=Reshape>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/mul_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/Switch' type=Switch>,
 <tf.Operation 'gradients/Shape_1' type=Shape>,
 <tf.Operation 'gradients/zeros/Const' type=Const>,
 <tf.Operation 'gradients/zeros' type=Fill>,
 <tf.Operation 'gradients/dropout_2/cond/Identity/Switch_grad/cond_grad' type=Merge>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/Shape_1' type=Const>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/BroadcastGradientArgs' type=BroadcastGradientArgs>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/RealDiv' type=RealDiv>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/Sum' type=Sum>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/Reshape' type=Reshape>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/Neg' type=Neg>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/RealDiv_1' type=RealDiv>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/RealDiv_2' type=RealDiv>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/mul' type=Mul>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/Sum_1' type=Sum>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/Reshape_1' type=Reshape>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/div_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/Switch_1' type=Switch>,
 <tf.Operation 'gradients/Shape_2' type=Shape>,
 <tf.Operation 'gradients/zeros_1/Const' type=Const>,
 <tf.Operation 'gradients/zeros_1' type=Fill>,
 <tf.Operation 'gradients/dropout_2/cond/dropout/Shape/Switch_grad/cond_grad' type=Merge>,
 <tf.Operation 'gradients/AddN' type=AddN>,
 <tf.Operation 'gradients/dense_1/Relu_grad/ReluGrad' type=ReluGrad>,
 <tf.Operation 'gradients/dense_1/BiasAdd_grad/BiasAddGrad' type=BiasAddGrad>,
 <tf.Operation 'gradients/dense_1/BiasAdd_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dense_1/BiasAdd_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dense_1/BiasAdd_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/dense_1/MatMul_grad/MatMul' type=MatMul>,
 <tf.Operation 'gradients/dense_1/MatMul_grad/MatMul_1' type=MatMul>,
 <tf.Operation 'gradients/dense_1/MatMul_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dense_1/MatMul_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dense_1/MatMul_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/Flatten/Reshape_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/Flatten/Reshape_grad/Reshape' type=Reshape>,
 <tf.Operation 'gradients/dropout_1/cond/Merge_grad/cond_grad' type=Switch>,
 <tf.Operation 'gradients/dropout_1/cond/Merge_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dropout_1/cond/Merge_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dropout_1/cond/Merge_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/Shape_1' type=Shape>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/BroadcastGradientArgs' type=BroadcastGradientArgs>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/mul' type=Mul>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/Sum' type=Sum>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/Reshape' type=Reshape>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/mul_1' type=Mul>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/Sum_1' type=Sum>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/Reshape_1' type=Reshape>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/mul_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/Switch_2' type=Switch>,
 <tf.Operation 'gradients/Shape_3' type=Shape>,
 <tf.Operation 'gradients/zeros_2/Const' type=Const>,
 <tf.Operation 'gradients/zeros_2' type=Fill>,
 <tf.Operation 'gradients/dropout_1/cond/Identity/Switch_grad/cond_grad' type=Merge>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/Shape_1' type=Const>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/BroadcastGradientArgs' type=BroadcastGradientArgs>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/RealDiv' type=RealDiv>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/Sum' type=Sum>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/Reshape' type=Reshape>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/Neg' type=Neg>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/RealDiv_1' type=RealDiv>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/RealDiv_2' type=RealDiv>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/mul' type=Mul>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/Sum_1' type=Sum>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/Reshape_1' type=Reshape>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/div_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/Switch_3' type=Switch>,
 <tf.Operation 'gradients/Shape_4' type=Shape>,
 <tf.Operation 'gradients/zeros_3/Const' type=Const>,
 <tf.Operation 'gradients/zeros_3' type=Fill>,
 <tf.Operation 'gradients/dropout_1/cond/dropout/Shape/Switch_grad/cond_grad' type=Merge>,
 <tf.Operation 'gradients/AddN_1' type=AddN>,
 <tf.Operation 'gradients/conv2d_2/Relu_grad/ReluGrad' type=ReluGrad>,
 <tf.Operation 'gradients/conv2d_2/BiasAdd_grad/BiasAddGrad' type=BiasAddGrad>,
 <tf.Operation 'gradients/conv2d_2/BiasAdd_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/conv2d_2/BiasAdd_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/conv2d_2/BiasAdd_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/conv2d_2/convolution_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/conv2d_2/convolution_grad/Conv2DBackpropInput' type=Conv2DBackpropInput>,
 <tf.Operation 'gradients/conv2d_2/convolution_grad/Shape_1' type=Const>,
 <tf.Operation 'gradients/conv2d_2/convolution_grad/Conv2DBackpropFilter' type=Conv2DBackpropFilter>,
 <tf.Operation 'gradients/conv2d_2/convolution_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/conv2d_2/convolution_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/conv2d_2/convolution_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/max_pooling2d_1/MaxPool_grad/MaxPoolGrad' type=MaxPoolGrad>,
 <tf.Operation 'gradients/conv2d_1/Relu_grad/ReluGrad' type=ReluGrad>,
 <tf.Operation 'gradients/conv2d_1/BiasAdd_grad/BiasAddGrad' type=BiasAddGrad>,
 <tf.Operation 'gradients/conv2d_1/BiasAdd_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/conv2d_1/BiasAdd_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/conv2d_1/BiasAdd_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'gradients/conv2d_1/convolution_grad/Shape' type=Shape>,
 <tf.Operation 'gradients/conv2d_1/convolution_grad/Conv2DBackpropInput' type=Conv2DBackpropInput>,
 <tf.Operation 'gradients/conv2d_1/convolution_grad/Shape_1' type=Const>,
 <tf.Operation 'gradients/conv2d_1/convolution_grad/Conv2DBackpropFilter' type=Conv2DBackpropFilter>,
 <tf.Operation 'gradients/conv2d_1/convolution_grad/tuple/group_deps' type=NoOp>,
 <tf.Operation 'gradients/conv2d_1/convolution_grad/tuple/control_dependency' type=Identity>,
 <tf.Operation 'gradients/conv2d_1/convolution_grad/tuple/control_dependency_1' type=Identity>,
 <tf.Operation 'beta1_power/initial_value' type=Const>,
 <tf.Operation 'beta1_power' type=VariableV2>,
 <tf.Operation 'beta1_power/Assign' type=Assign>,
 <tf.Operation 'beta1_power/read' type=Identity>,
 <tf.Operation 'beta2_power/initial_value' type=Const>,
 <tf.Operation 'beta2_power' type=VariableV2>,
 <tf.Operation 'beta2_power/Assign' type=Assign>,
 <tf.Operation 'beta2_power/read' type=Identity>,
 <tf.Operation 'conv2d_1/kernel/Adam/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_1/kernel/Adam' type=VariableV2>,
 <tf.Operation 'conv2d_1/kernel/Adam/Assign' type=Assign>,
 <tf.Operation 'conv2d_1/kernel/Adam/read' type=Identity>,
 <tf.Operation 'conv2d_1/kernel/Adam_1/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_1/kernel/Adam_1' type=VariableV2>,
 <tf.Operation 'conv2d_1/kernel/Adam_1/Assign' type=Assign>,
 <tf.Operation 'conv2d_1/kernel/Adam_1/read' type=Identity>,
 <tf.Operation 'conv2d_1/bias/Adam/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_1/bias/Adam' type=VariableV2>,
 <tf.Operation 'conv2d_1/bias/Adam/Assign' type=Assign>,
 <tf.Operation 'conv2d_1/bias/Adam/read' type=Identity>,
 <tf.Operation 'conv2d_1/bias/Adam_1/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_1/bias/Adam_1' type=VariableV2>,
 <tf.Operation 'conv2d_1/bias/Adam_1/Assign' type=Assign>,
 <tf.Operation 'conv2d_1/bias/Adam_1/read' type=Identity>,
 <tf.Operation 'conv2d_2/kernel/Adam/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_2/kernel/Adam' type=VariableV2>,
 <tf.Operation 'conv2d_2/kernel/Adam/Assign' type=Assign>,
 <tf.Operation 'conv2d_2/kernel/Adam/read' type=Identity>,
 <tf.Operation 'conv2d_2/kernel/Adam_1/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_2/kernel/Adam_1' type=VariableV2>,
 <tf.Operation 'conv2d_2/kernel/Adam_1/Assign' type=Assign>,
 <tf.Operation 'conv2d_2/kernel/Adam_1/read' type=Identity>,
 <tf.Operation 'conv2d_2/bias/Adam/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_2/bias/Adam' type=VariableV2>,
 <tf.Operation 'conv2d_2/bias/Adam/Assign' type=Assign>,
 <tf.Operation 'conv2d_2/bias/Adam/read' type=Identity>,
 <tf.Operation 'conv2d_2/bias/Adam_1/Initializer/zeros' type=Const>,
 <tf.Operation 'conv2d_2/bias/Adam_1' type=VariableV2>,
 <tf.Operation 'conv2d_2/bias/Adam_1/Assign' type=Assign>,
 <tf.Operation 'conv2d_2/bias/Adam_1/read' type=Identity>,
 <tf.Operation 'dense_1/kernel/Adam/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_1/kernel/Adam' type=VariableV2>,
 <tf.Operation 'dense_1/kernel/Adam/Assign' type=Assign>,
 <tf.Operation 'dense_1/kernel/Adam/read' type=Identity>,
 <tf.Operation 'dense_1/kernel/Adam_1/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_1/kernel/Adam_1' type=VariableV2>,
 <tf.Operation 'dense_1/kernel/Adam_1/Assign' type=Assign>,
 <tf.Operation 'dense_1/kernel/Adam_1/read' type=Identity>,
 <tf.Operation 'dense_1/bias/Adam/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_1/bias/Adam' type=VariableV2>,
 <tf.Operation 'dense_1/bias/Adam/Assign' type=Assign>,
 <tf.Operation 'dense_1/bias/Adam/read' type=Identity>,
 <tf.Operation 'dense_1/bias/Adam_1/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_1/bias/Adam_1' type=VariableV2>,
 <tf.Operation 'dense_1/bias/Adam_1/Assign' type=Assign>,
 <tf.Operation 'dense_1/bias/Adam_1/read' type=Identity>,
 <tf.Operation 'dense_2/kernel/Adam/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_2/kernel/Adam' type=VariableV2>,
 <tf.Operation 'dense_2/kernel/Adam/Assign' type=Assign>,
 <tf.Operation 'dense_2/kernel/Adam/read' type=Identity>,
 <tf.Operation 'dense_2/kernel/Adam_1/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_2/kernel/Adam_1' type=VariableV2>,
 <tf.Operation 'dense_2/kernel/Adam_1/Assign' type=Assign>,
 <tf.Operation 'dense_2/kernel/Adam_1/read' type=Identity>,
 <tf.Operation 'dense_2/bias/Adam/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_2/bias/Adam' type=VariableV2>,
 <tf.Operation 'dense_2/bias/Adam/Assign' type=Assign>,
 <tf.Operation 'dense_2/bias/Adam/read' type=Identity>,
 <tf.Operation 'dense_2/bias/Adam_1/Initializer/zeros' type=Const>,
 <tf.Operation 'dense_2/bias/Adam_1' type=VariableV2>,
 <tf.Operation 'dense_2/bias/Adam_1/Assign' type=Assign>,
 <tf.Operation 'dense_2/bias/Adam_1/read' type=Identity>,
 <tf.Operation 'Adam/learning_rate' type=Const>,
 <tf.Operation 'Adam/beta1' type=Const>,
 <tf.Operation 'Adam/beta2' type=Const>,
 <tf.Operation 'Adam/epsilon' type=Const>,
 <tf.Operation 'Adam/update_conv2d_1/kernel/ApplyAdam' type=ApplyAdam>,
 <tf.Operation 'Adam/update_conv2d_1/bias/ApplyAdam' type=ApplyAdam>,
 <tf.Operation 'Adam/update_conv2d_2/kernel/ApplyAdam' type=ApplyAdam>,
 <tf.Operation 'Adam/update_conv2d_2/bias/ApplyAdam' type=ApplyAdam>,
 <tf.Operation 'Adam/update_dense_1/kernel/ApplyAdam' type=ApplyAdam>,
 <tf.Operation 'Adam/update_dense_1/bias/ApplyAdam' type=ApplyAdam>,
 <tf.Operation 'Adam/update_dense_2/kernel/ApplyAdam' type=ApplyAdam>,
 <tf.Operation 'Adam/update_dense_2/bias/ApplyAdam' type=ApplyAdam>,
 <tf.Operation 'Adam/mul' type=Mul>,
 <tf.Operation 'Adam/Assign' type=Assign>,
 <tf.Operation 'Adam/mul_1' type=Mul>,
 <tf.Operation 'Adam/Assign_1' type=Assign>,
 <tf.Operation 'Adam' type=NoOp>,
 <tf.Operation 'ArgMax/dimension' type=Const>,
 <tf.Operation 'ArgMax' type=ArgMax>,
 <tf.Operation 'ArgMax_1/dimension' type=Const>,
 <tf.Operation 'ArgMax_1' type=ArgMax>,
 <tf.Operation 'Equal' type=Equal>,
 <tf.Operation 'Cast' type=Cast>,
 <tf.Operation 'Const' type=Const>,
 <tf.Operation 'Mean' type=Mean>,
 <tf.Operation 'init' type=NoOp>,
 <tf.Operation 'save/Const' type=Const>,
 <tf.Operation 'save/SaveV2/tensor_names' type=Const>,
 <tf.Operation 'save/SaveV2/shape_and_slices' type=Const>,
 <tf.Operation 'save/SaveV2' type=SaveV2>,
 <tf.Operation 'save/control_dependency' type=Identity>,
 <tf.Operation 'save/RestoreV2/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2' type=RestoreV2>,
 <tf.Operation 'save/Assign' type=Assign>,
 <tf.Operation 'save/RestoreV2_1/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_1/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_1' type=RestoreV2>,
 <tf.Operation 'save/Assign_1' type=Assign>,
 <tf.Operation 'save/RestoreV2_2/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_2/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_2' type=RestoreV2>,
 <tf.Operation 'save/Assign_2' type=Assign>,
 <tf.Operation 'save/RestoreV2_3/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_3/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_3' type=RestoreV2>,
 <tf.Operation 'save/Assign_3' type=Assign>,
 <tf.Operation 'save/RestoreV2_4/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_4/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_4' type=RestoreV2>,
 <tf.Operation 'save/Assign_4' type=Assign>,
 <tf.Operation 'save/RestoreV2_5/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_5/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_5' type=RestoreV2>,
 <tf.Operation 'save/Assign_5' type=Assign>,
 <tf.Operation 'save/RestoreV2_6/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_6/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_6' type=RestoreV2>,
 <tf.Operation 'save/Assign_6' type=Assign>,
 <tf.Operation 'save/RestoreV2_7/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_7/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_7' type=RestoreV2>,
 <tf.Operation 'save/Assign_7' type=Assign>,
 <tf.Operation 'save/RestoreV2_8/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_8/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_8' type=RestoreV2>,
 <tf.Operation 'save/Assign_8' type=Assign>,
 <tf.Operation 'save/RestoreV2_9/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_9/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_9' type=RestoreV2>,
 <tf.Operation 'save/Assign_9' type=Assign>,
 <tf.Operation 'save/RestoreV2_10/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_10/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_10' type=RestoreV2>,
 <tf.Operation 'save/Assign_10' type=Assign>,
 <tf.Operation 'save/RestoreV2_11/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_11/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_11' type=RestoreV2>,
 <tf.Operation 'save/Assign_11' type=Assign>,
 <tf.Operation 'save/RestoreV2_12/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_12/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_12' type=RestoreV2>,
 <tf.Operation 'save/Assign_12' type=Assign>,
 <tf.Operation 'save/RestoreV2_13/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_13/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_13' type=RestoreV2>,
 <tf.Operation 'save/Assign_13' type=Assign>,
 <tf.Operation 'save/RestoreV2_14/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_14/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_14' type=RestoreV2>,
 <tf.Operation 'save/Assign_14' type=Assign>,
 <tf.Operation 'save/RestoreV2_15/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_15/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_15' type=RestoreV2>,
 <tf.Operation 'save/Assign_15' type=Assign>,
 <tf.Operation 'save/RestoreV2_16/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_16/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_16' type=RestoreV2>,
 <tf.Operation 'save/Assign_16' type=Assign>,
 <tf.Operation 'save/RestoreV2_17/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_17/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_17' type=RestoreV2>,
 <tf.Operation 'save/Assign_17' type=Assign>,
 <tf.Operation 'save/RestoreV2_18/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_18/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_18' type=RestoreV2>,
 <tf.Operation 'save/Assign_18' type=Assign>,
 <tf.Operation 'save/RestoreV2_19/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_19/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_19' type=RestoreV2>,
 <tf.Operation 'save/Assign_19' type=Assign>,
 <tf.Operation 'save/RestoreV2_20/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_20/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_20' type=RestoreV2>,
 <tf.Operation 'save/Assign_20' type=Assign>,
 <tf.Operation 'save/RestoreV2_21/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_21/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_21' type=RestoreV2>,
 <tf.Operation 'save/Assign_21' type=Assign>,
 <tf.Operation 'save/RestoreV2_22/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_22/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_22' type=RestoreV2>,
 <tf.Operation 'save/Assign_22' type=Assign>,
 <tf.Operation 'save/RestoreV2_23/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_23/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_23' type=RestoreV2>,
 <tf.Operation 'save/Assign_23' type=Assign>,
 <tf.Operation 'save/RestoreV2_24/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_24/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_24' type=RestoreV2>,
 <tf.Operation 'save/Assign_24' type=Assign>,
 <tf.Operation 'save/RestoreV2_25/tensor_names' type=Const>,
 <tf.Operation 'save/RestoreV2_25/shape_and_slices' type=Const>,
 <tf.Operation 'save/RestoreV2_25' type=RestoreV2>,
 <tf.Operation 'save/Assign_25' type=Assign>,
 <tf.Operation 'save/restore_all' type=NoOp>]

In [13]:
input_tensor = sess.graph.get_operations()[0].outputs[0]
input_tensor


Out[13]:
<tf.Tensor 'Placeholder:0' shape=(?, 28, 28, 1) dtype=float32>

In [20]:
prediction_tensor = sess.graph.get_operation_by_name('dense_2/BiasAdd').outputs[0]
prediction_tensor


Out[20]:
<tf.Tensor 'dense_2/BiasAdd:0' shape=(?, 10) dtype=float32>

In [23]:
np.argmax(
    sess.run(prediction_tensor, feed_dict={input_tensor: test_data[:5]}),
    axis=-1)


Out[23]:
array([7, 2, 1, 0, 4])

Let's check whether the network was right.


In [25]:
for i in range(5):
    plt.imshow(test_data[i, ..., 0])
    plt.show()



In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: