Deep Learning

Assignment 2

Previously in 1_notmnist.ipynb, we created a pickle with formatted datasets for training, development and testing on the notMNIST dataset.

The goal of this assignment is to progressively train deeper and more accurate models using TensorFlow.


In [1]:
# These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range

First reload the data we generated in 1_notmnist.ipynb.


In [2]:
pickle_file = 'notMNIST.pickle'

with open(pickle_file, 'rb') as f:
  save = pickle.load(f)
  train_dataset = save['train_dataset']
  train_labels = save['train_labels']
  valid_dataset = save['valid_dataset']
  valid_labels = save['valid_labels']
  test_dataset = save['test_dataset']
  test_labels = save['test_labels']
  del save  # hint to help gc free up memory
  print('Training set', train_dataset.shape, train_labels.shape)
  print('Validation set', valid_dataset.shape, valid_labels.shape)
  print('Test set', test_dataset.shape, test_labels.shape)


Training set (200000, 28, 28) (200000,)
Validation set (10000, 28, 28) (10000,)
Test set (10000, 28, 28) (10000,)

Reformat into a shape that's more adapted to the models we're going to train:

  • data as a flat matrix,
  • labels as float 1-hot encodings.

In [3]:
image_size = 28
num_labels = 10

def reformat(dataset, labels):
  dataset = dataset.reshape((-1, image_size * image_size)).astype(np.float32)
  # Map 0 to [1.0, 0.0, 0.0 ...], 1 to [0.0, 1.0, 0.0 ...]
  labels = (np.arange(num_labels) == labels[:,None]).astype(np.float32)
  return dataset, labels
train_dataset, train_labels = reformat(train_dataset, train_labels)
valid_dataset, valid_labels = reformat(valid_dataset, valid_labels)
test_dataset, test_labels = reformat(test_dataset, test_labels)
print('Training set', train_dataset.shape, train_labels.shape)
print('Validation set', valid_dataset.shape, valid_labels.shape)
print('Test set', test_dataset.shape, test_labels.shape)


Training set (200000, 784) (200000, 10)
Validation set (10000, 784) (10000, 10)
Test set (10000, 784) (10000, 10)

We're first going to train a multinomial logistic regression using simple gradient descent.

TensorFlow works like this:

  • First you describe the computation that you want to see performed: what the inputs, the variables, and the operations look like. These get created as nodes over a computation graph. This description is all contained within the block below:

    with graph.as_default():
        ...
  • Then you can run the operations on this graph as many times as you want by calling session.run(), providing it outputs to fetch from the graph that get returned. This runtime operation is all contained in the block below:

    with tf.Session(graph=graph) as session:
        ...

Let's load all the data into TensorFlow and build the computation graph corresponding to our training:


In [4]:
# With gradient descent training, even this much data is prohibitive.
# Subset the training data for faster turnaround.
train_subset = 10000

graph = tf.Graph()
with graph.as_default():

  # Input data.
  # Load the training, validation and test data into constants that are
  # attached to the graph.
  tf_train_dataset = tf.constant(train_dataset[:train_subset, :])
  tf_train_labels = tf.constant(train_labels[:train_subset])
  tf_valid_dataset = tf.constant(valid_dataset)
  tf_test_dataset = tf.constant(test_dataset)
  
  # Variables.
  # These are the parameters that we are going to be training. The weight
  # matrix will be initialized using random values following a (truncated)
  # normal distribution. The biases get initialized to zero.
  weights = tf.Variable(
    tf.truncated_normal([image_size * image_size, num_labels]))
  biases = tf.Variable(tf.zeros([num_labels]))
  
  # Training computation.
  # We multiply the inputs with the weight matrix, and add biases. We compute
  # the softmax and cross-entropy (it's one operation in TensorFlow, because
  # it's very common, and it can be optimized). We take the average of this
  # cross-entropy across all training examples: that's our loss.
  logits = tf.matmul(tf_train_dataset, weights) + biases

  loss = tf.reduce_mean(
    tf.nn.softmax_cross_entropy_with_logits(labels=tf_train_labels, logits=logits))
  
  # Optimizer.
  # We are going to find the minimum of this loss using gradient descent.
  optimizer = tf.train.GradientDescentOptimizer(0.5).minimize(loss)
  
  # Predictions for the training, validation, and test data.
  # These are not part of training, but merely here so that we can report
  # accuracy figures as we train.
  train_prediction = tf.nn.softmax(logits)
  valid_prediction = tf.nn.softmax(
    tf.matmul(tf_valid_dataset, weights) + biases)
  test_prediction = tf.nn.softmax(tf.matmul(tf_test_dataset, weights) + biases)

Let's run this computation and iterate:


In [5]:
num_steps = 1000

def accuracy(predictions, labels):
  return (100.0 * np.sum(np.argmax(predictions, 1) == np.argmax(labels, 1))
          / predictions.shape[0])

with tf.Session(graph=graph) as session:
  # This is a one-time operation which ensures the parameters get initialized as
  # we described in the graph: random weights for the matrix, zeros for the
  # biases. 
  tf.global_variables_initializer().run()
  print('Initialized')
  for step in range(num_steps):
    # Run the computations. We tell .run() that we want to run the optimizer,
    # and get the loss value and the training predictions returned as numpy
    # arrays.
    _, l, predictions = session.run([optimizer, loss, train_prediction])
    if (step % 100 == 0):
      print('Loss at step %d: %f' % (step, l))
      print('Training accuracy: %.1f%%' % accuracy(
        predictions, train_labels[:train_subset, :]))
      # Calling .eval() on valid_prediction is basically like calling run(), but
      # just to get that one numpy array. Note that it recomputes all its graph
      # dependencies.
      print('Validation accuracy: %.1f%%' % accuracy(
        valid_prediction.eval(), valid_labels))
  print('Test accuracy: %.1f%%' % accuracy(test_prediction.eval(), test_labels))


Initialized
Loss at step 0: 14.541040
Training accuracy: 16.0%
Validation accuracy: 19.0%
Loss at step 100: 2.385364
Training accuracy: 70.8%
Validation accuracy: 69.5%
Loss at step 200: 1.913257
Training accuracy: 73.9%
Validation accuracy: 72.4%
Loss at step 300: 1.653569
Training accuracy: 75.2%
Validation accuracy: 73.6%
Loss at step 400: 1.481513
Training accuracy: 76.3%
Validation accuracy: 74.1%
Loss at step 500: 1.356224
Training accuracy: 77.1%
Validation accuracy: 74.3%
Loss at step 600: 1.259374
Training accuracy: 77.5%
Validation accuracy: 74.6%
Loss at step 700: 1.181337
Training accuracy: 78.0%
Validation accuracy: 74.8%
Loss at step 800: 1.116538
Training accuracy: 78.5%
Validation accuracy: 74.9%
Loss at step 900: 1.061630
Training accuracy: 79.0%
Validation accuracy: 75.1%
Test accuracy: 83.0%

Let's now switch to stochastic gradient descent training instead, which is much faster.

The graph will be similar, except that instead of holding all the training data into a constant node, we create a Placeholder node which will be fed actual data at every call of session.run().


In [6]:
batch_size = 128

graph = tf.Graph()
with graph.as_default():

  # Input data. For the training data, we use a placeholder that will be fed
  # at run time with a training minibatch.
  tf_train_dataset = tf.placeholder(tf.float32,
                                    shape=(batch_size, image_size * image_size))
  tf_train_labels = tf.placeholder(tf.float32, shape=(batch_size, num_labels))
  tf_valid_dataset = tf.constant(valid_dataset)
  tf_test_dataset = tf.constant(test_dataset)
  
  # Variables.
  weights = tf.Variable(
    tf.truncated_normal([image_size * image_size, num_labels]))
  biases = tf.Variable(tf.zeros([num_labels]))
  
  # Training computation.
  logits = tf.matmul(tf_train_dataset, weights) + biases
  loss = tf.reduce_mean(
    tf.nn.softmax_cross_entropy_with_logits(labels=tf_train_labels, logits=logits))
  
  # Optimizer.
  optimizer = tf.train.GradientDescentOptimizer(0.5).minimize(loss)
  
  # Predictions for the training, validation, and test data.
  train_prediction = tf.nn.softmax(logits)
  valid_prediction = tf.nn.softmax(
    tf.matmul(tf_valid_dataset, weights) + biases)
  test_prediction = tf.nn.softmax(tf.matmul(tf_test_dataset, weights) + biases)

Let's run it:


In [7]:
num_steps = 10001

with tf.Session(graph=graph) as session:
  tf.global_variables_initializer().run()
  print("Initialized")
  for step in range(num_steps):
    # Pick an offset within the training data, which has been randomized.
    # Note: we could use better randomization across epochs.
    offset = (step * batch_size) % (train_labels.shape[0] - batch_size)
    # Generate a minibatch.
    batch_data = train_dataset[offset:(offset + batch_size), :]
    batch_labels = train_labels[offset:(offset + batch_size), :]
    # Prepare a dictionary telling the session where to feed the minibatch.
    # The key of the dictionary is the placeholder node of the graph to be fed,
    # and the value is the numpy array to feed to it.
    feed_dict = {tf_train_dataset : batch_data, tf_train_labels : batch_labels}
    _, l, predictions = session.run(
      [optimizer, loss, train_prediction], feed_dict=feed_dict)
    if (step % 500 == 0):
      print("Minibatch loss at step %d: %f" % (step, l))
      print("Minibatch accuracy: %.1f%%" % accuracy(predictions, batch_labels))
      print("Validation accuracy: %.1f%%" % accuracy(
        valid_prediction.eval(), valid_labels))
  print("Test accuracy: %.1f%%" % accuracy(test_prediction.eval(), test_labels))


Initialized
Minibatch loss at step 0: 18.969223
Minibatch accuracy: 10.9%
Validation accuracy: 13.5%
Minibatch loss at step 500: 1.866254
Minibatch accuracy: 75.0%
Validation accuracy: 75.4%
Minibatch loss at step 1000: 1.863822
Minibatch accuracy: 71.9%
Validation accuracy: 76.6%
Minibatch loss at step 1500: 1.222958
Minibatch accuracy: 73.4%
Validation accuracy: 77.8%
Minibatch loss at step 2000: 0.768242
Minibatch accuracy: 83.6%
Validation accuracy: 77.9%
Minibatch loss at step 2500: 1.036196
Minibatch accuracy: 81.2%
Validation accuracy: 78.7%
Minibatch loss at step 3000: 0.961312
Minibatch accuracy: 82.0%
Validation accuracy: 78.5%
Minibatch loss at step 3500: 1.034209
Minibatch accuracy: 75.0%
Validation accuracy: 78.5%
Minibatch loss at step 4000: 0.952495
Minibatch accuracy: 74.2%
Validation accuracy: 79.1%
Minibatch loss at step 4500: 0.878106
Minibatch accuracy: 78.9%
Validation accuracy: 79.6%
Minibatch loss at step 5000: 0.702404
Minibatch accuracy: 83.6%
Validation accuracy: 80.0%
Minibatch loss at step 5500: 0.816820
Minibatch accuracy: 79.7%
Validation accuracy: 80.8%
Minibatch loss at step 6000: 0.773640
Minibatch accuracy: 82.8%
Validation accuracy: 80.3%
Minibatch loss at step 6500: 0.679559
Minibatch accuracy: 83.6%
Validation accuracy: 81.1%
Minibatch loss at step 7000: 0.696643
Minibatch accuracy: 77.3%
Validation accuracy: 80.8%
Minibatch loss at step 7500: 0.964423
Minibatch accuracy: 75.8%
Validation accuracy: 81.0%
Minibatch loss at step 8000: 0.676900
Minibatch accuracy: 78.9%
Validation accuracy: 81.2%
Minibatch loss at step 8500: 0.808097
Minibatch accuracy: 79.7%
Validation accuracy: 80.7%
Minibatch loss at step 9000: 0.670312
Minibatch accuracy: 83.6%
Validation accuracy: 81.4%
Minibatch loss at step 9500: 0.712499
Minibatch accuracy: 82.0%
Validation accuracy: 81.1%
Minibatch loss at step 10000: 0.874695
Minibatch accuracy: 74.2%
Validation accuracy: 81.8%
Test accuracy: 88.0%

Problem

Turn the logistic regression example with SGD into a 1-hidden layer neural network with rectified linear units nn.relu() and 1024 hidden nodes. This model should improve your validation / test accuracy.



In [33]:
pickle_file = 'notMNIST.pickle'

with open(pickle_file, 'rb') as f:
  save = pickle.load(f)
  train_dataset = save['train_dataset']
  train_labels = save['train_labels']
  valid_dataset = save['valid_dataset']
  valid_labels = save['valid_labels']
  test_dataset = save['test_dataset']
  test_labels = save['test_labels']
  del save  # hint to help gc free up memory
  print('Training set', train_dataset.shape, train_labels.shape)
  print('Validation set', valid_dataset.shape, valid_labels.shape)
  print('Test set', test_dataset.shape, test_labels.shape)

image_size = 28
num_labels = 10

def reformat(dataset, labels):
  dataset = dataset.reshape((-1, image_size * image_size)).astype(np.float32)
  # Map 0 to [1.0, 0.0, 0.0 ...], 1 to [0.0, 1.0, 0.0 ...]
  labels = (np.arange(num_labels) == labels[:,None]).astype(np.float32)
  return dataset, labels

train_dataset, train_labels = reformat(train_dataset, train_labels)
valid_dataset, valid_labels = reformat(valid_dataset, valid_labels)
test_dataset, test_labels = reformat(test_dataset, test_labels)
print('Training set', train_dataset.shape, train_labels.shape)
print('Validation set', valid_dataset.shape, valid_labels.shape)
print('Test set', test_dataset.shape, test_labels.shape)


Training set (200000, 28, 28) (200000,)
Validation set (10000, 28, 28) (10000,)
Test set (10000, 28, 28) (10000,)
Training set (200000, 784) (200000, 10)
Validation set (10000, 784) (10000, 10)
Test set (10000, 784) (10000, 10)

In [37]:
# Network Parameters
n_hidden_1 = 1024 # 1st layer number of features
#n_hidden_2 = 256 # 2nd layer number of features
#n_hidden_3 = 256 # 3nd layer number of features
n_input = 784 # notMNIST data input (img shape: 28*28)
n_classes = 10 # notMNIST total classes (0-9 digits)

# tf Graph input
x = tf.placeholder("float", [None, n_input])
y = tf.placeholder("float", [None, n_classes])

# Create model
def multilayer_perceptron(x, weights, biases):
    # Hidden layer with RELU activation
    layer_1 = tf.add(tf.matmul(x, weights['h1']), biases['b1'])
    layer_1 = tf.nn.relu(layer_1)
    # Hidden layer with RELU activation
#    layer_2 = tf.add(tf.matmul(layer_1, weights['h2']), biases['b2'])
#    layer_2 = tf.nn.relu(layer_2)
    # Hidden layer with RELU activation
#    layer_3 = tf.add(tf.matmul(layer_2, weights['h3']), biases['b3'])
#    layer_3 = tf.nn.relu(layer_3)
    # Output layer with linear activation
    out_layer = tf.matmul(layer_1, weights['out']) + biases['out']
    return out_layer

In [38]:
# Parameters
learning_rate = 0.001

# Store layers weight & bias
weights = {
    'h1': tf.Variable(tf.random_normal([n_input, n_hidden_1])),
#    'h2': tf.Variable(tf.random_normal([n_hidden_1, n_hidden_2])),
#    'h3': tf.Variable(tf.random_normal([n_hidden_2, n_hidden_3])),
    'out': tf.Variable(tf.random_normal([n_hidden_1, n_classes]))
}
biases = {
    'b1': tf.Variable(tf.random_normal([n_hidden_1])),
#    'b2': tf.Variable(tf.random_normal([n_hidden_2])),
#    'b3': tf.Variable(tf.random_normal([n_hidden_3])),
    'out': tf.Variable(tf.random_normal([n_classes]))
}

# Construct model
pred = multilayer_perceptron(x, weights, biases)

# Define loss and optimizer
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=pred, labels=y))
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)

# Test model
correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))

# Calculate accuracy
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))

In [36]:
#Parameters
training_epochs = 20
batch_size = 100
display_step = 1

# Launch the graph
with tf.Session() as sess:
    init = tf.global_variables_initializer()
    sess.run(init)

    # Training cycle
    for epoch in range(training_epochs):
        avg_cost = 0.
        total_batch = int(train_dataset.shape[0]/batch_size)
        # Loop over all batches
        for i in range(total_batch):
            offset = (i * batch_size) % (train_labels.shape[0] - batch_size)

            # Generate a minibatch.
            batch_x = train_dataset[offset:(offset + batch_size), :]
            batch_y = train_labels[offset:(offset + batch_size), :]
            # Run optimization op (backprop) and cost op (to get loss value)
            _, c = sess.run([optimizer, cost], feed_dict={x: batch_x,
                                                          y: batch_y})
            # Compute average loss
            avg_cost += c / total_batch
        # Display logs per epoch step
        if epoch % display_step == 0:
            print("Epoch %d: cost=%.1f valid_accuracy=%.1f%% train_accuracy=%.1f%%" % (epoch+1, avg_cost, (accuracy.eval({x: valid_dataset, y: valid_labels})*100), (accuracy.eval({x: train_dataset, y: train_labels})*100)))
            
    print("Optimization Finished!")

    print("test_accuracy: %.1f%%" % (accuracy.eval({x: test_dataset, y: test_labels})*100))


Epoch 1: cost=45.0 valid_accuracy=84.2% train_accuracy=85.6%
Epoch 2: cost=23.0 valid_accuracy=85.5% train_accuracy=87.8%
Epoch 3: cost=16.7 valid_accuracy=85.8% train_accuracy=89.1%
Epoch 4: cost=13.1 valid_accuracy=86.4% train_accuracy=89.9%
Epoch 5: cost=10.7 valid_accuracy=86.6% train_accuracy=90.5%
Epoch 6: cost=8.9 valid_accuracy=87.4% train_accuracy=92.2%
Epoch 7: cost=7.7 valid_accuracy=86.9% train_accuracy=92.0%
Epoch 8: cost=6.7 valid_accuracy=87.2% train_accuracy=92.4%
Epoch 9: cost=5.9 valid_accuracy=87.7% train_accuracy=93.1%
Epoch 10: cost=5.4 valid_accuracy=87.0% train_accuracy=92.6%
Epoch 11: cost=5.0 valid_accuracy=88.0% train_accuracy=93.7%
Epoch 12: cost=4.5 valid_accuracy=87.6% train_accuracy=93.6%
Epoch 13: cost=4.3 valid_accuracy=87.5% train_accuracy=93.3%
Epoch 14: cost=3.9 valid_accuracy=87.8% train_accuracy=94.2%
Epoch 15: cost=3.7 valid_accuracy=88.1% train_accuracy=94.1%
Epoch 16: cost=3.5 valid_accuracy=88.6% train_accuracy=95.3%
Epoch 17: cost=3.2 valid_accuracy=88.1% train_accuracy=94.3%
Epoch 18: cost=3.2 valid_accuracy=88.7% train_accuracy=95.6%
Epoch 19: cost=3.0 valid_accuracy=88.6% train_accuracy=95.1%
Epoch 20: cost=2.8 valid_accuracy=88.7% train_accuracy=95.6%
Optimization Finished!
test_accuracy: 93.5%

Problem - second version


In [82]:
#pickle_file = 'notMNIST_sanitized.pickle'
pickle_file = 'notMNIST.pickle'

with open(pickle_file, 'rb') as f:
  save = pickle.load(f)
  train_dataset = save['train_dataset']
  train_labels = save['train_labels']
  valid_dataset = save['valid_dataset']
  valid_labels = save['valid_labels']
  test_dataset = save['test_dataset']
  test_labels = save['test_labels']
  del save  # hint to help gc free up memory
  print('Training set', train_dataset.shape, train_labels.shape)
  print('Validation set', valid_dataset.shape, valid_labels.shape)
  print('Test set', test_dataset.shape, test_labels.shape)

image_size = 28
num_labels = 10

def reformat(dataset, labels):
  dataset = dataset.reshape((-1, image_size * image_size)).astype(np.float32)
  # Map 0 to [1.0, 0.0, 0.0 ...], 1 to [0.0, 1.0, 0.0 ...]
  labels = (np.arange(num_labels) == labels[:,None]).astype(np.float32)
  return dataset, labels

train_dataset, train_labels = reformat(train_dataset, train_labels)
valid_dataset, valid_labels = reformat(valid_dataset, valid_labels)
test_dataset, test_labels = reformat(test_dataset, test_labels)
print('Training set', train_dataset.shape, train_labels.shape)
print('Validation set', valid_dataset.shape, valid_labels.shape)
print('Test set', test_dataset.shape, test_labels.shape)


Training set (200000, 28, 28) (200000,)
Validation set (10000, 28, 28) (10000,)
Test set (10000, 28, 28) (10000,)
Training set (200000, 784) (200000, 10)
Validation set (10000, 784) (10000, 10)
Test set (10000, 784) (10000, 10)

In [83]:
batch_size = 128
hidden_nodes = 1024

graph = tf.Graph()
with graph.as_default():

  # Input data. For the training data, we use a placeholder that will be fed
  # at run time with a training minibatch.
  tf_train_dataset = tf.placeholder(tf.float32,
                                    shape=(batch_size, image_size * image_size))
  tf_train_labels = tf.placeholder(tf.float32, shape=(batch_size, num_labels))
  tf_valid_dataset = tf.constant(valid_dataset)
  tf_test_dataset = tf.constant(test_dataset)
  
  # Variables.
  weights_1 = tf.Variable(
    tf.truncated_normal([image_size * image_size, hidden_nodes]))
  biases_1 = tf.Variable(tf.zeros([hidden_nodes]))
  weights_2 = tf.Variable(
    tf.truncated_normal([hidden_nodes, num_labels]))
  biases_2 = tf.Variable(tf.zeros([num_labels]))
  
  # Training computation.
  def forward_prop(input):
    h1 = tf.nn.relu(tf.matmul(input, weights_1) + biases_1)
    return tf.matmul(h1, weights_2) + biases_2

  def accuracy(predictions, labels):
    return (100.0 * np.sum(np.argmax(predictions, 1) == np.argmax(labels, 1)) / predictions.shape[0])

  logits = forward_prop(tf_train_dataset)
  loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits, tf_train_labels))
  
  # Optimizer.
  optimizer = tf.train.AdamOptimizer(learning_rate=0.002).minimize(loss)
#  optimizer = tf.train.GradientDescentOptimizer(0.5).minimize(loss)
  
  # Predictions for the training, validation, and test data.
  train_prediction = tf.nn.softmax(logits)
  valid_prediction = tf.nn.softmax(forward_prop(tf_valid_dataset))
  test_prediction = tf.nn.softmax(forward_prop(tf_test_dataset))

In [84]:
num_steps = 5001

with tf.Session(graph=graph) as session:
  init = tf.global_variables_initializer()
  session.run(init)
  print("Initialized")
  for step in range(num_steps):
    # Pick an offset within the training data, which has been randomized.
    # Note: we could use better randomization across epochs.
    offset = (step * batch_size) % (train_labels.shape[0] - batch_size)
    # Generate a minibatch.
    batch_data = train_dataset[offset:(offset + batch_size), :]
    batch_labels = train_labels[offset:(offset + batch_size), :]
    # Prepare a dictionary telling the session where to feed the minibatch.
    # The key of the dictionary is the placeholder node of the graph to be fed,
    # and the value is the numpy array to feed to it.
    feed_dict = {tf_train_dataset : batch_data, tf_train_labels : batch_labels}
    _, l, predictions = session.run([optimizer, loss, train_prediction], feed_dict=feed_dict)
    if (step % 500 == 0):
      print("Minibatch loss at step %d: %f" % (step, l))
      print("Minibatch accuracy: %.1f%%" % accuracy(predictions, batch_labels))
      print("Validation accuracy: %.1f%%" % accuracy(valid_prediction.eval(), valid_labels))
  print("Test accuracy: %.1f%%" % accuracy(test_prediction.eval(), test_labels))


Initialized
Minibatch loss at step 0: 417.701050
Minibatch accuracy: 6.2%
Validation accuracy: 10.2%
Minibatch loss at step 500: 34.502018
Minibatch accuracy: 78.1%
Validation accuracy: 80.0%
Minibatch loss at step 1000: 29.511734
Minibatch accuracy: 75.0%
Validation accuracy: 81.8%
Minibatch loss at step 1500: 21.507788
Minibatch accuracy: 78.9%
Validation accuracy: 83.1%
Minibatch loss at step 2000: 6.518079
Minibatch accuracy: 90.6%
Validation accuracy: 83.1%
Minibatch loss at step 2500: 14.937896
Minibatch accuracy: 85.9%
Validation accuracy: 82.4%
Minibatch loss at step 3000: 9.876729
Minibatch accuracy: 84.4%
Validation accuracy: 84.6%
Minibatch loss at step 3500: 12.554543
Minibatch accuracy: 80.5%
Validation accuracy: 84.4%
Minibatch loss at step 4000: 8.516012
Minibatch accuracy: 83.6%
Validation accuracy: 85.1%
Minibatch loss at step 4500: 4.383387
Minibatch accuracy: 89.1%
Validation accuracy: 85.4%
Minibatch loss at step 5000: 5.705061
Minibatch accuracy: 89.1%
Validation accuracy: 85.7%
Test accuracy: 91.1%

In [ ]: