In [1]:
# Convolutional network with Tensorflow
import tensorflow as tf

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)

sess = tf.InteractiveSession()


Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz

In [2]:
# placeholders
x = tf.placeholder(tf.float32, shape=[None, 784])
y_ = tf.placeholder(tf.float32, shape=[None, 10])

In [17]:
# 2 functions for bias and weights variables
# initialization with a small values in order to prevent symmetry and dead neurons
def weight_variable(shape):
    initial = tf.truncated_normal(shape, stddev=0.1)
    return tf.Variable(initial)

def bias_variable(shape):
    initial = tf.constant(0.1, shape=shape)
    return tf.Variable(initial)

In [18]:
# 2 functions for convolution and pooling
def conv2d(x, W):
    return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')

def max_pool_2x2(x):
    return tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')

In [19]:
# first convolutional layer
W_conv1 = weight_variable([5, 5, 1, 32])  # 5*5 is patch size and 1 is the input dimension and 32 is the output dimension
b_conv1 = bias_variable([32])             # since we have 32 neurons

In [20]:
x_image = tf.reshape(x, [-1, 28, 28, 1])  # 28*28 is the size of picture and 1 is the number of color channels

In [21]:
# compute convolutional and max pooling for the first layer
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
h_pool1 = max_pool_2x2(h_conv1)

In [22]:
# second convolutional layer
W_conv2 = weight_variable([5, 5, 32, 64])  # 32 input and 64 output
b_conv2 = bias_variable([64])              # since we have 64 neurons

In [23]:
# compute convolutional and max pooling for the second layer
h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2)
h_pool2 = max_pool_2x2(h_conv2)

In [24]:
# densely fully connected layer
W_fc1 = weight_variable([7*7*64, 1024])
b_fc1 = bias_variable([1024])

h_pool2_flat = tf.reshape(h_pool2, [-1, 7*7*64])
h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1)

In [25]:
# dropout: we send a placeholder for that in order to enable it in training and disable it in testing
keep_prob = tf.placeholder(tf.float32)
h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob)

In [26]:
# softmax layer to compute the distribution for the final layer
W_fc2 = weight_variable([1024, 10])    # 10 because we have 10 classes (of digits)
b_fc2 = bias_variable([10])

y_conv = tf.nn.softmax(tf.matmul(h_fc1_drop, W_fc2) + b_fc2)

In [27]:
# train and evaluate the model
cross_entropy = -tf.reduce_sum(y_*tf.log(y_conv))
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
correct_prediction = tf.equal(tf.argmax(y_conv,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
sess.run(tf.initialize_all_variables())
for i in range(500):
  batch = mnist.train.next_batch(50)
  if i%100 == 0:
    train_accuracy = accuracy.eval(feed_dict={x:batch[0], y_: batch[1], keep_prob: 1.0})
    print("step %d, training accuracy %g"%(i, train_accuracy))
  train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})

print("test accuracy %g"%accuracy.eval(feed_dict={
    x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))


step 0, training accuracy 0.1
step 100, training accuracy 0.78
step 200, training accuracy 0.92
step 300, training accuracy 0.88
step 400, training accuracy 0.98
test accuracy 0.9436

In [28]:
W_conv2.eval()


Out[28]:
array([[[[  6.06222376e-02,  -4.15037461e-02,  -9.46073383e-02, ...,
           -1.27432287e-01,   1.24885151e-02,  -4.48169606e-03],
         [ -1.73523335e-03,   1.66072443e-01,   2.30698809e-02, ...,
           -6.50816709e-02,   5.83048314e-02,  -3.69798727e-02],
         [ -1.41949832e-01,  -7.57733872e-03,  -5.51790185e-02, ...,
            1.77838460e-01,  -4.55179401e-02,   3.90326902e-02],
         ..., 
         [  4.85178865e-02,  -3.02337557e-02,   2.64621507e-02, ...,
           -5.42729534e-02,  -1.85955912e-01,   5.49234301e-02],
         [ -1.51077285e-01,  -7.19259456e-02,   4.56884392e-02, ...,
           -2.49909125e-02,   4.95387502e-02,   2.99504623e-02],
         [  4.63772826e-02,   4.85757403e-02,  -7.28262961e-02, ...,
           -4.10926342e-02,  -2.77455393e-02,  -1.26076221e-01]],

        [[  3.29840928e-02,   1.80236995e-01,   1.30476296e-01, ...,
           -4.44657803e-02,   4.57179733e-02,  -6.10540435e-02],
         [ -8.15590546e-02,   6.83070067e-03,   5.02539910e-02, ...,
            1.35625144e-02,  -4.21604365e-02,   1.50172144e-01],
         [  1.43175468e-01,  -1.26215413e-01,  -7.33194361e-03, ...,
           -9.07743052e-02,  -1.07303120e-01,   9.64223314e-03],
         ..., 
         [  1.13826375e-02,   2.54197083e-02,  -4.27896790e-02, ...,
            1.37301788e-01,  -2.52973475e-02,   1.02451429e-01],
         [  1.94024399e-01,   8.58529806e-02,   5.85438684e-02, ...,
            1.35360301e-01,  -4.87762243e-02,   5.18029146e-02],
         [  5.14818169e-03,  -3.28563526e-02,   4.78627943e-02, ...,
           -1.20691627e-01,   2.48633884e-02,  -4.89823520e-02]],

        [[ -1.28910720e-01,   1.34335048e-02,   6.77113011e-02, ...,
            1.04233406e-01,  -1.51645944e-01,   1.14534423e-01],
         [ -7.20951799e-03,   9.82056782e-02,   9.44478586e-02, ...,
            1.66367710e-01,   8.81472826e-02,   4.52834517e-02],
         [  9.62602794e-02,  -8.41708705e-02,   7.02834204e-02, ...,
           -7.76552483e-02,  -1.52389659e-02,   3.17357704e-02],
         ..., 
         [  3.88282873e-02,  -6.08509853e-02,   5.14944345e-02, ...,
           -1.19557865e-01,   4.08367179e-02,   1.21914603e-01],
         [ -1.23414427e-01,  -5.47379330e-02,  -1.79366112e-01, ...,
           -2.48377789e-02,  -6.34233430e-02,   2.59861797e-02],
         [ -7.70530198e-03,  -9.62853432e-02,   1.85298726e-01, ...,
            4.36391532e-02,  -1.64841652e-01,  -1.20698713e-01]],

        [[ -7.21100196e-02,   3.53282094e-02,  -9.64435115e-02, ...,
            7.74071813e-02,  -4.16040309e-02,  -3.72143537e-02],
         [  1.59509540e-01,  -2.26901472e-02,   4.98121381e-02, ...,
            3.38883400e-02,  -1.97705790e-01,  -5.80809917e-03],
         [ -2.00843606e-02,  -1.56431377e-01,   7.96435475e-02, ...,
            1.10998981e-01,   2.40206290e-02,  -5.03773987e-03],
         ..., 
         [  6.66645914e-02,  -3.59826759e-02,   7.94879794e-02, ...,
            3.52597944e-02,   6.80073053e-02,  -1.40406460e-01],
         [  1.44198507e-01,   1.13495186e-01,  -5.23657389e-02, ...,
            1.63820796e-02,   2.21790485e-02,  -1.24512129e-01],
         [ -1.09631814e-01,   1.18512586e-01,   2.03819305e-01, ...,
            3.52664404e-02,   5.65617122e-02,   4.76069450e-02]],

        [[  3.22915278e-02,   1.88677460e-01,   2.79699266e-03, ...,
            7.90140182e-02,  -8.42673145e-03,   7.61283608e-03],
         [  9.26348008e-03,  -2.75404193e-02,   1.45480752e-01, ...,
            1.31369550e-02,  -1.39728654e-02,  -1.31579965e-01],
         [ -2.45093480e-02,  -8.37450624e-02,  -9.74452794e-02, ...,
           -4.39688861e-02,  -1.12308584e-01,   4.29533236e-02],
         ..., 
         [ -1.39924502e-02,   3.58820334e-02,   8.95459801e-02, ...,
            9.83114839e-02,  -1.03298742e-02,   6.50462657e-02],
         [ -1.23621330e-01,  -9.43968743e-02,  -1.48313016e-01, ...,
           -4.53856699e-02,   2.06492264e-02,  -5.03327930e-03],
         [ -1.02372162e-01,   1.83513328e-01,   1.87552363e-01, ...,
            1.26727708e-02,  -8.37451071e-02,   1.04822516e-01]]],


       [[[  1.13607056e-01,   5.48859686e-02,  -5.90737201e-02, ...,
           -2.71586385e-02,   6.24268828e-03,  -5.72439581e-02],
         [ -5.21178842e-02,   1.12814285e-01,  -9.91216768e-03, ...,
            1.31670326e-01,   1.07846335e-01,  -5.76455109e-02],
         [ -8.87512192e-02,   1.00170583e-01,   1.27030000e-01, ...,
           -2.69096419e-02,  -8.06899071e-02,   7.87911490e-02],
         ..., 
         [ -1.65136009e-02,   6.98598623e-02,  -1.19336009e-01, ...,
           -8.80937651e-02,  -5.43402834e-03,   6.19512834e-02],
         [ -1.48730546e-01,   4.32045795e-02,  -1.94146950e-02, ...,
           -3.45624089e-02,   8.69838148e-03,   1.55808136e-01],
         [  4.58822139e-02,  -3.05305012e-02,   1.18105680e-01, ...,
            9.84098539e-02,  -2.51261760e-02,   9.77389514e-02]],

        [[ -2.08414178e-02,   1.33398324e-01,   1.05469175e-01, ...,
           -7.67183155e-02,  -1.34764761e-01,   1.53438732e-01],
         [  9.59139839e-02,  -7.32525736e-02,   2.21720226e-02, ...,
           -4.39516939e-02,  -4.18717274e-03,   9.22998041e-02],
         [  1.87837295e-02,   1.23537473e-01,  -1.18856288e-01, ...,
           -1.80009276e-01,  -7.96932653e-02,  -1.64354771e-01],
         ..., 
         [ -1.54287731e-02,   3.13184708e-02,   8.95346925e-02, ...,
            7.11943805e-02,   3.68578881e-02,   1.16687819e-01],
         [  9.88187864e-02,   2.73728464e-02,   6.90744966e-02, ...,
           -8.26785713e-03,  -8.86263177e-02,   1.22042440e-01],
         [ -2.61224210e-02,   3.06107532e-02,   9.28156897e-02, ...,
            7.25616664e-02,  -1.26402482e-01,  -1.44216329e-01]],

        [[  1.90151781e-02,   3.20692547e-02,  -7.69862384e-02, ...,
            1.09134369e-01,  -4.18105945e-02,   1.15185186e-01],
         [ -3.78521718e-03,   7.32055977e-02,   6.53764680e-02, ...,
            4.68331203e-02,  -1.72963217e-02,   1.91400796e-02],
         [  7.46560618e-02,  -6.52586436e-03,   3.18451710e-02, ...,
            2.64122039e-02,   4.29852493e-02,   4.95917089e-02],
         ..., 
         [ -1.67997509e-01,   8.66582170e-02,   2.00881343e-02, ...,
            1.70874409e-02,  -4.52633575e-02,   1.60882950e-01],
         [  4.20658961e-02,  -8.88757855e-02,   1.42137334e-01, ...,
           -8.63341019e-02,   1.51375860e-01,  -2.76868716e-02],
         [ -1.32895693e-01,   4.77999821e-02,  -1.92295656e-01, ...,
            1.64118931e-02,   3.12919915e-03,   9.33949128e-02]],

        [[  6.68869540e-02,   7.56364539e-02,   2.20081974e-02, ...,
            9.35069770e-02,  -2.49643661e-02,   6.37548938e-02],
         [ -1.59405135e-02,   5.12595773e-02,   1.00248061e-01, ...,
            1.89914927e-02,  -3.49142142e-02,  -1.22444503e-01],
         [ -7.73022771e-02,   6.47629946e-02,  -1.33040592e-01, ...,
            2.42670458e-02,  -4.70960513e-02,   2.26368401e-02],
         ..., 
         [  8.17858949e-02,  -7.76397958e-02,  -5.80618978e-02, ...,
            1.27469478e-02,   1.51288360e-01,   1.00089349e-01],
         [ -4.22798954e-02,  -2.39786450e-02,   8.77967700e-02, ...,
           -9.65697765e-02,  -1.17757782e-01,   4.57954668e-02],
         [  2.58106198e-02,   8.19262341e-02,   1.30104832e-02, ...,
            1.66703258e-02,   3.18454625e-03,  -5.40167466e-02]],

        [[ -2.67047957e-02,  -1.80653855e-02,  -4.17697569e-03, ...,
            8.51623490e-02,   3.36343870e-02,  -1.17042236e-01],
         [ -1.27578840e-01,   1.70660540e-01,   6.80838749e-02, ...,
           -1.07041344e-01,   2.14119023e-03,  -7.09888432e-03],
         [ -1.38751656e-01,   7.93581735e-03,   1.18250921e-01, ...,
            1.40294582e-02,   7.34274536e-02,   1.62884757e-01],
         ..., 
         [ -5.86536042e-02,  -6.82220459e-02,  -1.48017615e-01, ...,
            1.61669627e-01,   1.26686171e-01,   9.42318290e-02],
         [ -1.60322249e-01,   7.35048056e-02,  -1.65188700e-01, ...,
            1.21216156e-01,  -3.50902528e-02,   3.52350343e-03],
         [  1.85388669e-01,   1.04353078e-01,  -2.53063086e-02, ...,
           -1.32123325e-02,  -1.35597080e-01,  -3.47088613e-02]]],


       [[[  1.11224227e-01,  -7.27723688e-02,   9.84641686e-02, ...,
            1.19260490e-01,  -1.35917589e-01,  -3.18657868e-02],
         [  2.16658853e-04,   6.15426488e-02,   6.50783814e-03, ...,
           -1.19104767e-02,  -1.02900840e-01,   5.35509400e-02],
         [  1.36273280e-02,   4.60701063e-02,  -1.00534670e-01, ...,
            1.04818799e-01,   1.28597409e-01,   3.89781445e-02],
         ..., 
         [ -1.14416055e-01,   5.66955395e-02,  -1.35233492e-01, ...,
            3.14863659e-02,   3.18200663e-02,   1.21593900e-01],
         [ -1.58681452e-01,  -6.33271784e-02,  -4.38885838e-02, ...,
            7.82766417e-02,   1.20778099e-01,   1.38697490e-01],
         [  9.80693847e-02,   8.26558173e-02,   7.32546896e-02, ...,
            2.31589079e-02,   4.32977155e-02,  -1.24443531e-01]],

        [[  2.92267953e-03,   1.01360463e-01,   5.06250821e-02, ...,
            4.95813116e-02,  -1.24051861e-01,  -9.87527892e-02],
         [  1.51422083e-01,   3.99127193e-02,   7.17757568e-02, ...,
            9.75505412e-02,   1.33355886e-01,   4.44614179e-02],
         [ -1.53147325e-01,  -1.52228594e-01,   5.12779132e-02, ...,
           -1.70542821e-01,   1.05306499e-01,   8.00625756e-02],
         ..., 
         [  1.54549137e-01,  -4.27006297e-02,  -2.60437094e-02, ...,
           -3.55142355e-02,   5.48145957e-02,  -1.01400226e-01],
         [  8.94768387e-02,  -1.04908258e-01,  -8.57768580e-02, ...,
           -5.03167175e-02,  -4.54997085e-03,  -9.45552513e-02],
         [  1.12933956e-01,  -1.70397878e-01,   7.23947287e-02, ...,
           -3.41784488e-03,  -6.85021207e-02,  -5.38855679e-02]],

        [[  1.43514305e-01,  -3.38823646e-02,   2.59334259e-02, ...,
            3.92373316e-02,   7.22286180e-02,  -4.31640772e-03],
         [  1.55079275e-01,   6.40084296e-02,  -6.23552017e-02, ...,
           -5.43642491e-02,   6.81550149e-03,  -6.23218715e-02],
         [ -1.16577357e-01,  -1.13809854e-01,  -9.32919011e-02, ...,
            1.34854158e-03,  -1.22214049e-01,   1.27090737e-01],
         ..., 
         [ -3.67663093e-02,   7.17767328e-02,   3.06128506e-02, ...,
            1.50539372e-02,  -4.46991101e-02,  -4.59800065e-02],
         [ -1.09263852e-01,   8.26871470e-02,  -2.14140285e-02, ...,
            1.02450773e-02,  -5.67242950e-02,  -1.70920715e-01],
         [ -9.95561597e-04,   6.07754476e-03,   1.87600806e-01, ...,
           -9.94897857e-02,   1.42154358e-02,   1.04889542e-01]],

        [[ -1.53244749e-01,   4.94243624e-03,  -3.08397226e-02, ...,
            6.30013719e-02,   7.40821520e-03,   1.79148942e-01],
         [  2.61327997e-02,   1.72159206e-02,   8.49654991e-03, ...,
           -1.45717099e-01,  -7.25815864e-03,   4.77304459e-02],
         [  1.67199075e-02,   1.71307083e-02,  -6.71732649e-02, ...,
           -1.33641586e-01,  -3.54627110e-02,  -3.68491709e-02],
         ..., 
         [ -1.56479150e-01,   8.95171091e-02,   1.91537723e-01, ...,
           -1.68920751e-03,  -9.29124653e-02,  -1.41395688e-01],
         [  1.78386226e-01,  -6.11865781e-02,  -1.82690129e-01, ...,
           -7.59184957e-02,   1.37740914e-02,   1.47436798e-01],
         [ -2.05488428e-02,  -3.19609717e-02,   8.11766833e-02, ...,
            7.39317536e-02,  -3.44500169e-02,   1.56920478e-02]],

        [[ -4.02515940e-02,   5.91601618e-02,  -6.59227045e-03, ...,
            6.50054738e-02,   2.15301923e-02,   1.61980882e-01],
         [ -3.57884355e-02,  -1.07835852e-01,   6.75399005e-02, ...,
            5.08420393e-02,   3.98856737e-02,   4.11247797e-02],
         [  1.95963345e-02,  -1.20531432e-02,  -1.42750458e-03, ...,
           -3.38077173e-02,   2.58129537e-02,  -1.69177234e-01],
         ..., 
         [  3.55791859e-02,   4.01923358e-02,   3.88140343e-02, ...,
            5.11222482e-02,   2.90497337e-02,   1.75065383e-01],
         [ -1.11454517e-01,  -1.50374010e-01,   2.63518766e-02, ...,
           -1.05073694e-02,  -1.09144650e-01,   3.39977816e-02],
         [  1.17876247e-01,   7.15352371e-02,  -1.09556139e-01, ...,
           -9.84621793e-03,   1.17960796e-01,   1.49327204e-01]]],


       [[[  1.03424527e-01,  -8.17357823e-02,  -1.13558844e-02, ...,
           -1.34237148e-02,   7.43503682e-03,   4.67679277e-02],
         [  2.55923588e-02,   1.11779362e-01,   1.37026817e-01, ...,
            9.97354835e-02,  -5.73984534e-02,   1.84719935e-01],
         [  3.56400087e-02,   4.49338555e-02,   1.62054390e-01, ...,
            1.11769252e-02,  -1.02953933e-01,   1.21544607e-01],
         ..., 
         [  1.53736815e-01,  -1.37170136e-01,  -6.33912832e-02, ...,
            9.72655192e-02,   6.13328889e-02,   2.17090491e-02],
         [ -1.78113759e-01,   1.38223961e-01,   7.49607161e-02, ...,
           -2.73337476e-02,  -1.46030292e-01,  -7.81945884e-02],
         [  8.74680355e-02,   2.09793169e-02,  -5.41423224e-02, ...,
           -3.87568101e-02,  -3.91066559e-02,   4.04040255e-02]],

        [[ -1.57794520e-01,   1.24551713e-01,   7.53204450e-02, ...,
           -9.51170251e-02,   6.89669177e-02,  -1.03765823e-01],
         [ -4.59479615e-02,   1.39139090e-02,  -3.98591757e-02, ...,
           -1.49976209e-01,   6.67012623e-03,   8.41907859e-02],
         [ -1.01262681e-01,   4.35789488e-03,  -3.29704098e-02, ...,
            1.32962495e-01,  -7.73618147e-02,   7.65305012e-02],
         ..., 
         [  1.29773587e-01,   9.69842672e-02,   1.75515279e-01, ...,
            8.62829015e-02,   1.24963820e-02,   7.91397914e-02],
         [ -1.12819508e-01,  -6.91005141e-02,   4.79413606e-02, ...,
           -1.60740718e-01,  -2.72406451e-02,  -8.87997076e-02],
         [  3.12024448e-02,   3.49520519e-02,   1.78232029e-01, ...,
           -3.81719880e-02,   7.41710886e-02,   7.42864907e-02]],

        [[ -1.33299589e-01,   1.37020886e-01,   1.17056547e-02, ...,
            7.61804953e-02,  -1.63018942e-01,  -5.99120883e-03],
         [ -6.82272762e-03,   9.88767073e-02,   1.20469235e-01, ...,
           -6.26550429e-03,  -2.46413369e-02,   4.79160696e-02],
         [  5.84011041e-02,   1.34499860e-03,   8.42784941e-02, ...,
           -2.24419758e-02,  -3.11378054e-02,  -1.01419225e-01],
         ..., 
         [ -1.10487938e-01,  -4.47328426e-02,   7.68592283e-02, ...,
           -1.87508255e-01,   1.91250861e-01,   1.17217377e-01],
         [  5.75006865e-02,  -1.15849078e-01,  -3.69211659e-02, ...,
           -9.24647376e-02,   4.98126401e-03,  -7.71135241e-02],
         [  9.35180637e-04,  -3.64859216e-02,   1.86312467e-01, ...,
            1.71599351e-02,   1.19439833e-01,   3.70895974e-02]],

        [[  7.87244067e-02,   3.64093017e-03,   8.58367756e-02, ...,
            6.97864220e-02,   1.04505152e-01,   7.56103992e-02],
         [ -2.91758589e-02,  -2.27776002e-02,   5.09052388e-02, ...,
           -2.22217999e-02,   3.54490466e-02,   5.57088256e-02],
         [  5.86251840e-02,   1.50485083e-01,  -6.80275634e-02, ...,
            3.95503715e-02,  -7.34791011e-02,  -3.43501605e-02],
         ..., 
         [ -4.46989052e-02,   4.52465117e-02,   1.79588273e-02, ...,
            1.53731778e-01,   1.29416674e-01,  -9.29315165e-02],
         [  1.25926211e-01,  -4.84136790e-02,  -9.59715713e-03, ...,
            1.11341275e-01,  -1.15384236e-01,   5.34569696e-02],
         [  9.07463506e-02,   2.27828436e-02,   2.01380588e-02, ...,
           -8.54106620e-02,  -8.13252777e-02,   9.02156997e-03]],

        [[  6.05910011e-02,  -3.12581775e-03,  -7.42644072e-02, ...,
            7.74019733e-02,  -3.84856425e-02,   9.76270959e-02],
         [  6.77057058e-02,  -1.55382216e-01,  -3.33815627e-02, ...,
           -1.10470407e-01,  -4.06908505e-02,   1.25776589e-01],
         [ -5.97638786e-02,  -7.56158540e-03,   4.60280478e-02, ...,
           -6.86484668e-03,  -7.87090231e-03,  -1.18938740e-03],
         ..., 
         [ -5.63333882e-03,  -1.84349850e-01,   1.38253695e-03, ...,
           -1.95540898e-02,   1.09342694e-01,   3.78958918e-02],
         [  1.43003926e-01,   2.31781993e-02,  -1.55181438e-01, ...,
            1.79553941e-01,  -9.16566402e-02,   8.43378529e-03],
         [ -9.02171656e-02,  -4.52033281e-02,  -5.32421358e-02, ...,
            6.76782662e-03,  -4.74165641e-02,   2.10665986e-02]]],


       [[[ -7.69354105e-02,   2.95121018e-02,  -5.11729680e-02, ...,
            1.30275469e-02,  -1.60533451e-02,  -7.65781999e-02],
         [  9.20284241e-02,   1.33439854e-01,   2.69271284e-02, ...,
            1.35701140e-02,   1.21474497e-01,   9.28693861e-02],
         [ -7.77176172e-02,   5.33948913e-02,   1.05211753e-02, ...,
           -7.39586800e-02,  -8.30717385e-02,   3.63570116e-02],
         ..., 
         [  4.36754078e-02,   1.40554504e-02,  -3.90196103e-03, ...,
           -1.26964152e-02,   1.00883767e-01,   1.57692090e-01],
         [ -9.44990665e-02,  -2.36203019e-02,  -1.89763650e-01, ...,
           -9.00166705e-02,  -1.18413761e-01,  -8.60279649e-02],
         [  7.34606609e-02,  -1.33415654e-01,  -9.08163786e-02, ...,
            1.23373717e-01,   4.78841737e-02,  -8.95565227e-02]],

        [[ -6.25955835e-02,  -2.92339511e-02,  -7.90413544e-02, ...,
            7.50441104e-02,  -5.00139929e-02,  -2.00427175e-02],
         [  8.74937251e-02,   3.82638797e-02,  -1.69861186e-02, ...,
           -3.77841406e-02,  -1.74607053e-01,  -2.97568506e-03],
         [ -5.61267249e-02,   8.46831203e-02,  -5.61826676e-02, ...,
            7.88056180e-02,  -7.41661638e-02,   7.22429305e-02],
         ..., 
         [  1.58940107e-02,  -1.64816529e-01,   2.47336868e-02, ...,
           -3.19767073e-02,  -9.40227807e-02,   1.89737827e-02],
         [  9.12411585e-02,   4.93742339e-02,   6.01217821e-02, ...,
            1.29812494e-01,  -8.97442363e-03,  -2.11393274e-03],
         [  6.03637695e-02,   1.02335088e-01,  -1.20473020e-01, ...,
            6.67460412e-02,  -1.86111487e-03,  -1.44496432e-03]],

        [[  1.05035938e-01,  -2.38186046e-02,  -2.38994602e-02, ...,
           -4.63749729e-02,   4.07439135e-02,   1.53492223e-02],
         [  1.16208792e-01,  -5.49611486e-02,   7.73609281e-02, ...,
            5.35091422e-02,   1.07692517e-01,   7.30790943e-02],
         [  4.68406864e-02,  -1.62433796e-02,  -1.66286975e-02, ...,
           -6.01734258e-02,   1.52330369e-01,  -1.67615578e-01],
         ..., 
         [  7.89289735e-03,   3.62028517e-02,   1.06084287e-01, ...,
            3.04530356e-02,   3.16935927e-02,  -5.85805587e-02],
         [  1.86902788e-02,   2.09314562e-02,   4.15027440e-02, ...,
            1.36740878e-01,  -4.31493968e-02,  -4.27092910e-02],
         [  1.89516563e-02,   1.87198557e-02,   1.13763381e-02, ...,
           -5.56062832e-02,  -1.75117496e-02,  -4.52749059e-02]],

        [[ -1.58385649e-01,  -4.56481212e-05,   1.47203162e-01, ...,
           -1.62177533e-02,   1.60556853e-01,  -3.74161676e-02],
         [ -4.29928079e-02,   6.56803772e-02,   9.17548966e-03, ...,
            2.17259917e-02,  -4.59572449e-02,   7.20746368e-02],
         [  1.35705844e-01,  -1.54644623e-03,  -4.43124063e-02, ...,
            8.05973709e-02,   1.22115180e-01,  -1.29642719e-02],
         ..., 
         [  9.11450759e-02,  -1.20506600e-01,   2.27531455e-02, ...,
           -1.34869844e-01,   1.07296735e-01,   6.86602294e-02],
         [ -1.42617673e-01,  -1.87573694e-02,   7.11134523e-02, ...,
            6.51458325e-03,   8.01157728e-02,  -9.40279383e-03],
         [ -1.12790689e-02,  -3.73035371e-02,   1.26172537e-02, ...,
            3.49765755e-02,   7.43974969e-02,  -1.45593453e-02]],

        [[  4.22097892e-02,   5.23200817e-02,  -1.12159722e-01, ...,
           -9.67418626e-02,  -4.85525057e-02,   1.21327722e-02],
         [  8.40524510e-02,  -2.87801642e-02,   2.42250450e-02, ...,
           -4.76235040e-02,   1.10003941e-01,   1.09256662e-01],
         [  6.35743588e-02,  -3.29838023e-02,  -5.18945828e-02, ...,
            4.36445251e-02,   2.86236242e-03,   2.81218812e-03],
         ..., 
         [  1.40235454e-01,   2.78657358e-02,  -3.97995003e-02, ...,
            2.38235090e-02,  -6.63375407e-02,  -9.00189485e-03],
         [  1.19916216e-01,   3.81405354e-02,  -1.44275740e-01, ...,
            8.42889473e-02,  -1.13866948e-01,  -1.24327481e-01],
         [ -2.98500862e-02,   5.85721843e-02,   1.47136167e-01, ...,
           -1.10322192e-01,  -1.90021154e-02,   4.18613143e-02]]]], dtype=float32)

In [ ]: