Anna KaRNNa

In this notebook, we'll build a character-wise RNN trained on Anna Karenina, one of my all-time favorite books. It'll be able to generate new text based on the text from the book.

This network is based off of Andrej Karpathy's post on RNNs and implementation in Torch. Also, some information here at r2rt and from Sherjil Ozair on GitHub. Below is the general architecture of the character-wise RNN.

In [1]:
import time
from collections import namedtuple

import numpy as np
import tensorflow as tf

First we'll load the text file and convert it into integers for our network to use. Here I'm creating a couple dictionaries to convert the characters to and from integers. Encoding the characters as integers makes it easier to use as input in the network.

In [2]:
with open('anna.txt', 'r') as f:
    text=f.read()
vocab = sorted(set(text))
vocab_to_int = {c: i for i, c in enumerate(vocab)}
int_to_vocab = dict(enumerate(vocab))
encoded = np.array([vocab_to_int[c] for c in text], dtype=np.int32)
In [13]:
int_to_vocab
Out[13]:
{0: '\n',
 1: ' ',
 2: '!',
 3: '"',
 4: '$',
 5: '%',
 6: '&',
 7: "'",
 8: '(',
 9: ')',
 10: '*',
 11: ',',
 12: '-',
 13: '.',
 14: '/',
 15: '0',
 16: '1',
 17: '2',
 18: '3',
 19: '4',
 20: '5',
 21: '6',
 22: '7',
 23: '8',
 24: '9',
 25: ':',
 26: ';',
 27: '?',
 28: '@',
 29: 'A',
 30: 'B',
 31: 'C',
 32: 'D',
 33: 'E',
 34: 'F',
 35: 'G',
 36: 'H',
 37: 'I',
 38: 'J',
 39: 'K',
 40: 'L',
 41: 'M',
 42: 'N',
 43: 'O',
 44: 'P',
 45: 'Q',
 46: 'R',
 47: 'S',
 48: 'T',
 49: 'U',
 50: 'V',
 51: 'W',
 52: 'X',
 53: 'Y',
 54: 'Z',
 55: '_',
 56: '`',
 57: 'a',
 58: 'b',
 59: 'c',
 60: 'd',
 61: 'e',
 62: 'f',
 63: 'g',
 64: 'h',
 65: 'i',
 66: 'j',
 67: 'k',
 68: 'l',
 69: 'm',
 70: 'n',
 71: 'o',
 72: 'p',
 73: 'q',
 74: 'r',
 75: 's',
 76: 't',
 77: 'u',
 78: 'v',
 79: 'w',
 80: 'x',
 81: 'y',
 82: 'z'}

Let's check out the first 100 characters, make sure everything is peachy. According to the American Book Review, this is the 6th best first line of a book ever.

In [11]:
text[:100]
Out[11]:
'Chapter 1\n\n\nHappy families are all alike; every unhappy family is unhappy in its own\nway.\n\nEverythin'

And we can see the characters encoded as integers.

In [12]:
encoded[:100]
Out[12]:
array([31, 64, 57, 72, 76, 61, 74,  1, 16,  0,  0,  0, 36, 57, 72, 72, 81,
        1, 62, 57, 69, 65, 68, 65, 61, 75,  1, 57, 74, 61,  1, 57, 68, 68,
        1, 57, 68, 65, 67, 61, 26,  1, 61, 78, 61, 74, 81,  1, 77, 70, 64,
       57, 72, 72, 81,  1, 62, 57, 69, 65, 68, 81,  1, 65, 75,  1, 77, 70,
       64, 57, 72, 72, 81,  1, 65, 70,  1, 65, 76, 75,  1, 71, 79, 70,  0,
       79, 57, 81, 13,  0,  0, 33, 78, 61, 74, 81, 76, 64, 65, 70],
      dtype=int32)

Since the network is working with individual characters, it's similar to a classification problem in which we are trying to predict the next character from the previous text. Here's how many 'classes' our network has to pick from.

Making training mini-batches

Here is where we'll make our mini-batches for training. Remember that we want our batches to be multiple sequences of some desired number of sequence steps. Considering a simple example, our batches would look like this:


We start with our text encoded as integers in one long array in encoded. Let's create a function that will give us an iterator for our batches. I like using generator functions to do this. Then we can pass encoded into this function and get our batch generator.

The first thing we need to do is discard some of the text so we only have completely full batches. Each batch contains $N \times M$ characters, where $N$ is the batch size (the number of sequences) and $M$ is the number of steps. Then, to get the total number of batches, $K$, we can make from the array arr, you divide the length of arr by the number of characters per batch. Once you know the number of batches, you can get the total number of characters to keep from arr, $N * M * K$.

After that, we need to split arr into $N$ sequences. You can do this using arr.reshape(size) where size is a tuple containing the dimensions sizes of the reshaped array. We know we want $N$ sequences (batch_size below), let's make that the size of the first dimension. For the second dimension, you can use -1 as a placeholder in the size, it'll fill up the array with the appropriate data for you. After this, you should have an array that is $N \times (M * K)$.

Now that we have this array, we can iterate through it to get our batches. The idea is each batch is a $N \times M$ window on the $N \times (M * K)$ array. For each subsequent batch, the window moves over by n_steps. We also want to create both the input and target arrays. Remember that the targets are the inputs shifted over one character.

The way I like to do this window is use range to take steps of size n_steps from $0$ to arr.shape[1], the total number of steps in each sequence. That way, the integers you get from range always point to the start of a batch, and each window is n_steps wide.

Exercise: Write the code for creating batches in the function below. The exercises in this notebook will not be easy. I've provided a notebook with solutions alongside this notebook. If you get stuck, checkout the solutions. The most important thing is that you don't copy and paste the code into here, type out the solution code yourself.

In [60]:
def get_batches(arr, batch_size, n_steps):
    '''Create a generator that returns batches of size
       batch_size x n_steps from arr.
       
       Arguments
       ---------
       arr: Array you want to make batches from
       batch_size: Batch size, the number of sequences per batch
       n_steps: Number of sequence steps per batch
    '''
    # Get the number of characters per batch and number of batches we can make
    characters_per_batch = batch_size * n_steps
    n_batches = len(arr) // characters_per_batch
    
    # Keep only enough characters to make full batches
    arr = arr[:characters_per_batch*n_batches]
    
    # Reshape into batch_size rows
    arr = arr.reshape((batch_size,-1))
    
    for n in range(0, arr.shape[1], n_steps):
        # The features
        x = arr[:,n:n+n_steps]
        # The targets, shifted by one
        y_temp = arr[:, n+1:n+n_steps+1]
        y = np.zeros(x.shape, dtype=x.dtype)
        y[:,:y_temp.shape[1]] = y_temp
        yield x, y

Now I'll make my data sets and we can check out what's going on here. Here I'm going to use a batch size of 10 and 50 sequence steps.

In [61]:
batches = get_batches(encoded, 10, 50)
x, y = next(batches)
In [66]:
x.shape
Out[66]:
(10, 50)
In [68]:
print('x\n', x[:, :])
print('\ny\n', y[:10, :])
x
 [[31 64 57 72 76 61 74  1 16  0  0  0 36 57 72 72 81  1 62 57 69 65 68 65
  61 75  1 57 74 61  1 57 68 68  1 57 68 65 67 61 26  1 61 78 61 74 81  1
  77 70]
 [ 1 57 69  1 70 71 76  1 63 71 65 70 63  1 76 71  1 75 76 57 81 11  3  1
  57 70 75 79 61 74 61 60  1 29 70 70 57 11  1 75 69 65 68 65 70 63 11  1
  58 77]
 [78 65 70 13  0  0  3 53 61 75 11  1 65 76  7 75  1 75 61 76 76 68 61 60
  13  1 48 64 61  1 72 74 65 59 61  1 65 75  1 69 57 63 70 65 62 65 59 61
  70 76]
 [70  1 60 77 74 65 70 63  1 64 65 75  1 59 71 70 78 61 74 75 57 76 65 71
  70  1 79 65 76 64  1 64 65 75  0 58 74 71 76 64 61 74  1 79 57 75  1 76
  64 65]
 [ 1 65 76  1 65 75 11  1 75 65 74  2  3  1 75 57 65 60  1 76 64 61  1 71
  68 60  1 69 57 70 11  1 63 61 76 76 65 70 63  1 77 72 11  1 57 70 60  0
  59 74]
 [ 1 37 76  1 79 57 75  0 71 70 68 81  1 79 64 61 70  1 76 64 61  1 75 57
  69 61  1 61 78 61 70 65 70 63  1 64 61  1 59 57 69 61  1 76 71  1 76 64
  61 65]
 [64 61 70  1 59 71 69 61  1 62 71 74  1 69 61 11  3  1 75 64 61  1 75 57
  65 60 11  1 57 70 60  1 79 61 70 76  1 58 57 59 67  1 65 70 76 71  1 76
  64 61]
 [26  1 58 77 76  1 70 71 79  1 75 64 61  1 79 71 77 68 60  1 74 61 57 60
  65 68 81  1 64 57 78 61  1 75 57 59 74 65 62 65 59 61 60 11  1 70 71 76
   1 69]
 [76  1 65 75 70  7 76 13  1 48 64 61 81  7 74 61  1 72 74 71 72 74 65 61
  76 71 74 75  1 71 62  1 57  1 75 71 74 76 11  0 58 77 76  1 79 61  7 74
  61  1]
 [ 1 75 57 65 60  1 76 71  1 64 61 74 75 61 68 62 11  1 57 70 60  1 58 61
  63 57 70  1 57 63 57 65 70  1 62 74 71 69  1 76 64 61  1 58 61 63 65 70
  70 65]]

y
 [[64 57 72 76 61 74  1 16  0  0  0 36 57 72 72 81  1 62 57 69 65 68 65 61
  75  1 57 74 61  1 57 68 68  1 57 68 65 67 61 26  1 61 78 61 74 81  1 77
  70 64]
 [57 69  1 70 71 76  1 63 71 65 70 63  1 76 71  1 75 76 57 81 11  3  1 57
  70 75 79 61 74 61 60  1 29 70 70 57 11  1 75 69 65 68 65 70 63 11  1 58
  77 76]
 [65 70 13  0  0  3 53 61 75 11  1 65 76  7 75  1 75 61 76 76 68 61 60 13
   1 48 64 61  1 72 74 65 59 61  1 65 75  1 69 57 63 70 65 62 65 59 61 70
  76 26]
 [ 1 60 77 74 65 70 63  1 64 65 75  1 59 71 70 78 61 74 75 57 76 65 71 70
   1 79 65 76 64  1 64 65 75  0 58 74 71 76 64 61 74  1 79 57 75  1 76 64
  65 75]
 [65 76  1 65 75 11  1 75 65 74  2  3  1 75 57 65 60  1 76 64 61  1 71 68
  60  1 69 57 70 11  1 63 61 76 76 65 70 63  1 77 72 11  1 57 70 60  0 59
  74 71]
 [37 76  1 79 57 75  0 71 70 68 81  1 79 64 61 70  1 76 64 61  1 75 57 69
  61  1 61 78 61 70 65 70 63  1 64 61  1 59 57 69 61  1 76 71  1 76 64 61
  65 74]
 [61 70  1 59 71 69 61  1 62 71 74  1 69 61 11  3  1 75 64 61  1 75 57 65
  60 11  1 57 70 60  1 79 61 70 76  1 58 57 59 67  1 65 70 76 71  1 76 64
  61  1]
 [ 1 58 77 76  1 70 71 79  1 75 64 61  1 79 71 77 68 60  1 74 61 57 60 65
  68 81  1 64 57 78 61  1 75 57 59 74 65 62 65 59 61 60 11  1 70 71 76  1
  69 61]
 [ 1 65 75 70  7 76 13  1 48 64 61 81  7 74 61  1 72 74 71 72 74 65 61 76
  71 74 75  1 71 62  1 57  1 75 71 74 76 11  0 58 77 76  1 79 61  7 74 61
   1 76]
 [75 57 65 60  1 76 71  1 64 61 74 75 61 68 62 11  1 57 70 60  1 58 61 63
  57 70  1 57 63 57 65 70  1 62 74 71 69  1 76 64 61  1 58 61 63 65 70 70
  65 70]]

If you implemented get_batches correctly, the above output should look something like

x
 [[55 63 69 22  6 76 45  5 16 35]
 [ 5 69  1  5 12 52  6  5 56 52]
 [48 29 12 61 35 35  8 64 76 78]
 [12  5 24 39 45 29 12 56  5 63]
 [ 5 29  6  5 29 78 28  5 78 29]
 [ 5 13  6  5 36 69 78 35 52 12]
 [63 76 12  5 18 52  1 76  5 58]
 [34  5 73 39  6  5 12 52 36  5]
 [ 6  5 29 78 12 79  6 61  5 59]
 [ 5 78 69 29 24  5  6 52  5 63]]

y
 [[63 69 22  6 76 45  5 16 35 35]
 [69  1  5 12 52  6  5 56 52 29]
 [29 12 61 35 35  8 64 76 78 28]
 [ 5 24 39 45 29 12 56  5 63 29]
 [29  6  5 29 78 28  5 78 29 45]
 [13  6  5 36 69 78 35 52 12 43]
 [76 12  5 18 52  1 76  5 58 52]
 [ 5 73 39  6  5 12 52 36  5 78]
 [ 5 29 78 12 79  6 61  5 59 63]
 [78 69 29 24  5  6 52  5 63 76]]

although the exact numbers will be different. Check to make sure the data is shifted over one step for y.

Building the model

Below is where you'll build the network. We'll break it up into parts so it's easier to reason about each bit. Then we can connect them up into the whole network.

Inputs

First off we'll create our input placeholders. As usual we need placeholders for the training data and the targets. We'll also create a placeholder for dropout layers called keep_prob. This will be a scalar, that is a 0-D tensor. To make a scalar, you create a placeholder without giving it a size.

Exercise: Create the input placeholders in the function below.

In [69]:
def build_inputs(batch_size, num_steps):
    ''' Define placeholders for inputs, targets, and dropout 
    
        Arguments
        ---------
        batch_size: Batch size, number of sequences per batch
        num_steps: Number of sequence steps in a batch
        
    '''
    # Declare placeholders we'll feed into the graph
    inputs = tf.placeholder(tf.int32,shape = [batch_size, num_steps], name='inputs')
    targets = tf.placeholder(tf.int32, [batch_size, num_steps], name='targets')
    
    # Keep probability placeholder for drop out layers
    keep_prob = tf.placeholder(tf.float32, name='keep_prob')
    
    return inputs, targets, keep_prob

LSTM Cell

Here we will create the LSTM cell we'll use in the hidden layer. We'll use this cell as a building block for the RNN. So we aren't actually defining the RNN here, just the type of cell we'll use in the hidden layer.

We first create a basic LSTM cell with

lstm = tf.contrib.rnn.BasicLSTMCell(num_units)

where num_units is the number of units in the hidden layers in the cell. Then we can add dropout by wrapping it with

tf.contrib.rnn.DropoutWrapper(lstm, output_keep_prob=keep_prob)

You pass in a cell and it will automatically add dropout to the inputs or outputs. Finally, we can stack up the LSTM cells into layers with tf.contrib.rnn.MultiRNNCell. With this, you pass in a list of cells and it will send the output of one cell into the next cell. Previously with TensorFlow 1.0, you could do this

tf.contrib.rnn.MultiRNNCell([cell]*num_layers)

This might look a little weird if you know Python well because this will create a list of the same cell object. However, TensorFlow 1.0 will create different weight matrices for all cell objects. But, starting with TensorFlow 1.1 you actually need to create new cell objects in the list. To get it to work in TensorFlow 1.1, it should look like

def build_cell(num_units, keep_prob):
    lstm = tf.contrib.rnn.BasicLSTMCell(num_units)
    drop = tf.contrib.rnn.DropoutWrapper(lstm, output_keep_prob=keep_prob)

    return drop

tf.contrib.rnn.MultiRNNCell([build_cell(num_units, keep_prob) for _ in range(num_layers)])

Even though this is actually multiple LSTM cells stacked on each other, you can treat the multiple layers as one cell.

We also need to create an initial cell state of all zeros. This can be done like so

initial_state = cell.zero_state(batch_size, tf.float32)

Below, we implement the build_lstm function to create these LSTM cells and the initial state.

In [70]:
def build_lstm(lstm_size, num_layers, batch_size, keep_prob):
    ''' Build LSTM cell.
    
        Arguments
        ---------
        keep_prob: Scalar tensor (tf.placeholder) for the dropout keep probability
        lstm_size: Size of the hidden layers in the LSTM cells
        num_layers: Number of LSTM layers
        batch_size: Batch size

    '''
    ### Build the LSTM Cell
    def build_cell(lstm_size, keep_prob):
        # Use a basic LSTM cell
        lstm = tf.contrib.rnn.BasicLSTMCell(lstm_size)
        
        # Add dropout to the cell
        drop = tf.contrib.rnn.DropoutWrapper(lstm, output_keep_prob=keep_prob)
        return drop
    

    # Stack up multiple LSTM layers, for deep learning
    cell = tf.contrib.rnn.MultiRNNCell([build_cell(lstm_size, keep_prob) for _ in range(num_layers)])
    initial_state = cell.zero_state(batch_size, tf.float32)
    
    return cell, initial_state

RNN Output

Here we'll create the output layer. We need to connect the output of the RNN cells to a full connected layer with a softmax output. The softmax output gives us a probability distribution we can use to predict the next character, so we want this layer to have size $C$, the number of classes/characters we have in our text.

If our input has batch size $N$, number of steps $M$, and the hidden layer has $L$ hidden units, then the output is a 3D tensor with size $N \times M \times L$. The output of each LSTM cell has size $L$, we have $M$ of them, one for each sequence step, and we have $N$ sequences. So the total size is $N \times M \times L$.

We are using the same fully connected layer, the same weights, for each of the outputs. Then, to make things easier, we should reshape the outputs into a 2D tensor with shape $(M * N) \times L$. That is, one row for each sequence and step, where the values of each row are the output from the LSTM cells. We get the LSTM output as a list, lstm_output. First we need to concatenate this whole list into one array with tf.concat. Then, reshape it (with tf.reshape) to size $(M * N) \times L$.

One we have the outputs reshaped, we can do the matrix multiplication with the weights. We need to wrap the weight and bias variables in a variable scope with tf.variable_scope(scope_name) because there are weights being created in the LSTM cells. TensorFlow will throw an error if the weights created here have the same names as the weights created in the LSTM cells, which they will be default. To avoid this, we wrap the variables in a variable scope so we can give them unique names.

Exercise: Implement the output layer in the function below.

In [81]:
def build_output(lstm_output, in_size, out_size):
    ''' Build a softmax layer, return the softmax output and logits.
    
        Arguments
        ---------
        
        lstm_output: List of output tensors from the LSTM layer
        in_size: Size of the input tensor, for example, size of the LSTM cells
        out_size: Size of this softmax layer
    
    '''

    # Reshape output so it's a bunch of rows, one row for each step for each sequence.
    # Concatenate lstm_output over axis 1 (the columns)
    seq_output = tf.concat(lstm_output, axis=1)
    # Reshape seq_output to a 2D tensor with lstm_size columns
    x = tf.reshape(seq_output, [-1, in_size])
    
    # Connect the RNN outputs to a softmax layer
    with tf.variable_scope('softmax'):
        # Create the weight and bias variables here
        softmax_w = tf.Variable(tf.truncated_normal((in_size, out_size), stddev=0.1))
        softmax_b = tf.Variable(tf.zeros(out_size))
    
    # Since output is a bunch of rows of RNN cell outputs, logits will be a bunch
    # of rows of logit outputs, one for each step and sequence
    logits = tf.matmul(x, softmax_w) + softmax_b
    
    # Use softmax to get the probabilities for predicted characters
    out = tf.nn.softmax(logits, name='predictions')
    
    return out, logits

Training loss

Next up is the training loss. We get the logits and targets and calculate the softmax cross-entropy loss. First we need to one-hot encode the targets, we're getting them as encoded characters. Then, reshape the one-hot targets so it's a 2D tensor with size $(M*N) \times C$ where $C$ is the number of classes/characters we have. Remember that we reshaped the LSTM outputs and ran them through a fully connected layer with $C$ units. So our logits will also have size $(M*N) \times C$.

Then we run the logits and targets through tf.nn.softmax_cross_entropy_with_logits and find the mean to get the loss.

Exercise: Implement the loss calculation in the function below.

In [87]:
def build_loss(logits, targets, lstm_size, num_classes):
    ''' Calculate the loss from the logits and the targets.
    
        Arguments
        ---------
        logits: Logits from final fully connected layer
        targets: Targets for supervised learning
        lstm_size: Number of LSTM hidden units
        num_classes: Number of classes in targets
        
    '''
    
    # One-hot encode targets and reshape to match logits, one row per sequence per step
    y_one_hot = tf.one_hot(targets, num_classes)
    y_reshaped =  tf.reshape(y_one_hot, logits.get_shape())
    print('y_one_hot:' , y_one_hot.shape , "y_reshaped : " , y_reshaped.shape)
    
    # Softmax cross entropy loss
    loss = tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=y_reshaped)
    loss = tf.reduce_mean(loss)
    
    return loss

Optimizer

Here we build the optimizer. Normal RNNs have have issues gradients exploding and disappearing. LSTMs fix the disappearance problem, but the gradients can still grow without bound. To fix this, we can clip the gradients above some threshold. That is, if a gradient is larger than that threshold, we set it to the threshold. This will ensure the gradients never grow overly large. Then we use an AdamOptimizer for the learning step.

In [88]:
def build_optimizer(loss, learning_rate, grad_clip):
    ''' Build optmizer for training, using gradient clipping.
    
        Arguments:
        loss: Network loss
        learning_rate: Learning rate for optimizer
    
    '''
    
    # Optimizer for training, using gradient clipping to control exploding gradients
    tvars = tf.trainable_variables()
    grads, _ = tf.clip_by_global_norm(tf.gradients(loss, tvars), grad_clip)
    train_op = tf.train.AdamOptimizer(learning_rate)
    optimizer = train_op.apply_gradients(zip(grads, tvars))
    
    return optimizer

Build the network

Now we can put all the pieces together and build a class for the network. To actually run data through the LSTM cells, we will use tf.nn.dynamic_rnn. This function will pass the hidden and cell states across LSTM cells appropriately for us. It returns the outputs for each LSTM cell at each step for each sequence in the mini-batch. It also gives us the final LSTM state. We want to save this state as final_state so we can pass it to the first LSTM cell in the the next mini-batch run. For tf.nn.dynamic_rnn, we pass in the cell and initial state we get from build_lstm, as well as our input sequences. Also, we need to one-hot encode the inputs before going into the RNN.

Exercise: Use the functions you've implemented previously and tf.nn.dynamic_rnn to build the network.

In [89]:
class CharRNN:
    
    def __init__(self, num_classes, batch_size=64, num_steps=50, 
                       lstm_size=128, num_layers=2, learning_rate=0.001, 
                       grad_clip=5, sampling=False):
    
        # When we're using this network for sampling later, we'll be passing in
        # one character at a time, so providing an option for that
        if sampling == True:
            batch_size, num_steps = 1, 1
        else:
            batch_size, num_steps = batch_size, num_steps

        tf.reset_default_graph()
        
        # Build the input placeholder tensors
        self.inputs, self.targets, self.keep_prob = build_inputs(batch_size, num_steps)

        # Build the LSTM cell
        cell, self.initial_state = build_lstm(lstm_size, num_layers, batch_size, self.keep_prob)

        ### Run the data through the RNN layers
        # First, one-hot encode the input tokens
        x_one_hot = tf.one_hot(self.inputs, num_classes)
        
        # Run each sequence step through the RNN with tf.nn.dynamic_rnn 
        outputs, state = tf.nn.dynamic_rnn(cell, x_one_hot, initial_state=self.initial_state)
        self.final_state = state
        
        # Get softmax predictions and logits
        self.prediction, self.logits = build_output(outputs, lstm_size, num_classes)
        
        # Loss and optimizer (with gradient clipping)
        self.loss = build_loss(self.logits, self.targets, lstm_size, num_classes)
        self.optimizer = build_optimizer(self.loss, learning_rate, grad_clip)

Hyperparameters

Here are the hyperparameters for the network.

  • batch_size - Number of sequences running through the network in one pass.
  • num_steps - Number of characters in the sequence the network is trained on. Larger is better typically, the network will learn more long range dependencies. But it takes longer to train. 100 is typically a good number here.
  • lstm_size - The number of units in the hidden layers.
  • num_layers - Number of hidden LSTM layers to use
  • learning_rate - Learning rate for training
  • keep_prob - The dropout keep probability when training. If you're network is overfitting, try decreasing this.

Here's some good advice from Andrej Karpathy on training the network. I'm going to copy it in here for your benefit, but also link to where it originally came from.

Tips and Tricks

Monitoring Validation Loss vs. Training Loss

If you're somewhat new to Machine Learning or Neural Networks it can take a bit of expertise to get good models. The most important quantity to keep track of is the difference between your training loss (printed during training) and the validation loss (printed once in a while when the RNN is run on the validation data (by default every 1000 iterations)). In particular:

  • If your training loss is much lower than validation loss then this means the network might be overfitting. Solutions to this are to decrease your network size, or to increase dropout. For example you could try dropout of 0.5 and so on.
  • If your training/validation loss are about equal then your model is underfitting. Increase the size of your model (either number of layers or the raw number of neurons per layer)

Approximate number of parameters

The two most important parameters that control the model are lstm_size and num_layers. I would advise that you always use num_layers of either 2/3. The lstm_size can be adjusted based on how much data you have. The two important quantities to keep track of here are:

  • The number of parameters in your model. This is printed when you start training.
  • The size of your dataset. 1MB file is approximately 1 million characters.

These two should be about the same order of magnitude. It's a little tricky to tell. Here are some examples:

  • I have a 100MB dataset and I'm using the default parameter settings (which currently print 150K parameters). My data size is significantly larger (100 mil >> 0.15 mil), so I expect to heavily underfit. I am thinking I can comfortably afford to make lstm_size larger.
  • I have a 10MB dataset and running a 10 million parameter model. I'm slightly nervous and I'm carefully monitoring my validation loss. If it's larger than my training loss then I may want to try to increase dropout a bit and see if that helps the validation loss.

Best models strategy

The winning strategy to obtaining very good models (if you have the compute time) is to always err on making the network larger (as large as you're willing to wait for it to compute) and then try different dropout values (between 0,1). Whatever model has the best validation performance (the loss, written in the checkpoint filename, low is good) is the one you should use in the end.

It is very common in deep learning to run many different models with many different hyperparameter settings, and in the end take whatever checkpoint gave the best validation performance.

By the way, the size of your training and validation splits are also parameters. Make sure you have a decent amount of data in your validation set or otherwise the validation performance will be noisy and not very informative.

In [90]:
batch_size = 10         # Sequences per batch
num_steps = 50          # Number of sequence steps per batch
lstm_size = 128         # Size of hidden layers in LSTMs
num_layers = 2          # Number of LSTM layers
learning_rate = 0.01    # Learning rate
keep_prob = 0.5         # Dropout keep probability

Time for training

This is typical training code, passing inputs and targets into the network, then running the optimizer. Here we also get back the final LSTM state for the mini-batch. Then, we pass that state back into the network so the next batch can continue the state from the previous batch. And every so often (set by save_every_n) I save a checkpoint.

Here I'm saving checkpoints with the format

i{iteration number}_l{# hidden layer units}.ckpt

Exercise: Set the hyperparameters above to train the network. Watch the training loss, it should be consistently dropping. Also, I highly advise running this on a GPU.

In [91]:
epochs = 20
# Print losses every N interations
print_every_n = 50

# Save every N iterations
save_every_n = 200

model = CharRNN(len(vocab), batch_size=batch_size, num_steps=num_steps,
                lstm_size=lstm_size, num_layers=num_layers, 
                learning_rate=learning_rate)

saver = tf.train.Saver(max_to_keep=100)
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    
    # Use the line below to load a checkpoint and resume training
    #saver.restore(sess, 'checkpoints/______.ckpt')
    counter = 0
    for e in range(epochs):
        # Train network
        new_state = sess.run(model.initial_state)
        loss = 0
        for x, y in get_batches(encoded, batch_size, num_steps):
            counter += 1
            start = time.time()
            feed = {model.inputs: x,
                    model.targets: y,
                    model.keep_prob: keep_prob,
                    model.initial_state: new_state}
            batch_loss, new_state, _ = sess.run([model.loss, 
                                                 model.final_state, 
                                                 model.optimizer], 
                                                 feed_dict=feed)
            if (counter % print_every_n == 0):
                end = time.time()
                print('Epoch: {}/{}... '.format(e+1, epochs),
                      'Training Step: {}... '.format(counter),
                      'Training loss: {:.4f}... '.format(batch_loss),
                      '{:.4f} sec/batch'.format((end-start)))
        
            if (counter % save_every_n == 0):
                saver.save(sess, "checkpoints/i{}_l{}.ckpt".format(counter, lstm_size))
    
    saver.save(sess, "checkpoints/i{}_l{}.ckpt".format(counter, lstm_size))
y_one_hot: (10, 50, 83) y_reshaped :  (500, 83)
WARNING:tensorflow:From <ipython-input-87-594ebda341ec>:19: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See @{tf.nn.softmax_cross_entropy_with_logits_v2}.

Epoch: 1/20...  Training Step: 50...  Training loss: 3.1326...  0.0807 sec/batch
Epoch: 1/20...  Training Step: 100...  Training loss: 2.7357...  0.0750 sec/batch
Epoch: 1/20...  Training Step: 150...  Training loss: 2.4888...  0.0764 sec/batch
Epoch: 1/20...  Training Step: 200...  Training loss: 2.4571...  0.0959 sec/batch
Epoch: 1/20...  Training Step: 250...  Training loss: 2.3798...  0.0732 sec/batch
Epoch: 1/20...  Training Step: 300...  Training loss: 2.2221...  0.0767 sec/batch
Epoch: 1/20...  Training Step: 350...  Training loss: 2.1410...  0.0787 sec/batch
Epoch: 1/20...  Training Step: 400...  Training loss: 2.1589...  0.0793 sec/batch
Epoch: 1/20...  Training Step: 450...  Training loss: 2.2446...  0.1015 sec/batch
Epoch: 1/20...  Training Step: 500...  Training loss: 2.2583...  0.0835 sec/batch
Epoch: 1/20...  Training Step: 550...  Training loss: 1.9108...  0.0789 sec/batch
Epoch: 1/20...  Training Step: 600...  Training loss: 1.9107...  0.0824 sec/batch
Epoch: 1/20...  Training Step: 650...  Training loss: 1.8995...  0.0786 sec/batch
Epoch: 1/20...  Training Step: 700...  Training loss: 1.9375...  0.1024 sec/batch
Epoch: 1/20...  Training Step: 750...  Training loss: 2.0632...  0.1387 sec/batch
Epoch: 1/20...  Training Step: 800...  Training loss: 1.9891...  0.0883 sec/batch
Epoch: 1/20...  Training Step: 850...  Training loss: 2.1151...  0.0773 sec/batch
Epoch: 1/20...  Training Step: 900...  Training loss: 1.9365...  0.1095 sec/batch
Epoch: 1/20...  Training Step: 950...  Training loss: 1.9788...  0.0829 sec/batch
Epoch: 1/20...  Training Step: 1000...  Training loss: 1.9068...  0.0806 sec/batch
Epoch: 1/20...  Training Step: 1050...  Training loss: 1.9162...  0.0806 sec/batch
Epoch: 1/20...  Training Step: 1100...  Training loss: 1.9016...  0.0960 sec/batch
Epoch: 1/20...  Training Step: 1150...  Training loss: 1.9528...  0.0861 sec/batch
Epoch: 1/20...  Training Step: 1200...  Training loss: 1.8802...  0.0997 sec/batch
Epoch: 1/20...  Training Step: 1250...  Training loss: 1.6840...  0.0864 sec/batch
Epoch: 1/20...  Training Step: 1300...  Training loss: 1.8475...  0.0984 sec/batch
Epoch: 1/20...  Training Step: 1350...  Training loss: 1.7175...  0.1218 sec/batch
Epoch: 1/20...  Training Step: 1400...  Training loss: 2.0297...  0.1379 sec/batch
Epoch: 1/20...  Training Step: 1450...  Training loss: 1.8883...  0.0869 sec/batch
Epoch: 1/20...  Training Step: 1500...  Training loss: 1.9174...  0.0867 sec/batch
Epoch: 1/20...  Training Step: 1550...  Training loss: 1.8211...  0.0976 sec/batch
Epoch: 1/20...  Training Step: 1600...  Training loss: 1.8787...  0.0810 sec/batch
Epoch: 1/20...  Training Step: 1650...  Training loss: 1.8353...  0.0798 sec/batch
Epoch: 1/20...  Training Step: 1700...  Training loss: 1.8899...  0.0841 sec/batch
Epoch: 1/20...  Training Step: 1750...  Training loss: 1.8971...  0.0759 sec/batch
Epoch: 1/20...  Training Step: 1800...  Training loss: 1.9007...  0.0834 sec/batch
Epoch: 1/20...  Training Step: 1850...  Training loss: 1.9550...  0.0737 sec/batch
Epoch: 1/20...  Training Step: 1900...  Training loss: 1.6908...  0.0974 sec/batch
Epoch: 1/20...  Training Step: 1950...  Training loss: 1.7823...  0.0886 sec/batch
Epoch: 1/20...  Training Step: 2000...  Training loss: 1.8354...  0.0770 sec/batch
Epoch: 1/20...  Training Step: 2050...  Training loss: 1.9728...  0.0701 sec/batch
Epoch: 1/20...  Training Step: 2100...  Training loss: 1.8121...  0.0901 sec/batch
Epoch: 1/20...  Training Step: 2150...  Training loss: 1.7966...  0.0869 sec/batch
Epoch: 1/20...  Training Step: 2200...  Training loss: 1.7431...  0.0829 sec/batch
Epoch: 1/20...  Training Step: 2250...  Training loss: 1.7560...  0.0797 sec/batch
Epoch: 1/20...  Training Step: 2300...  Training loss: 1.6870...  0.0814 sec/batch
Epoch: 1/20...  Training Step: 2350...  Training loss: 1.8939...  0.0945 sec/batch
Epoch: 1/20...  Training Step: 2400...  Training loss: 1.8326...  0.0945 sec/batch
Epoch: 1/20...  Training Step: 2450...  Training loss: 1.9198...  0.1183 sec/batch
Epoch: 1/20...  Training Step: 2500...  Training loss: 1.7585...  0.0801 sec/batch
Epoch: 1/20...  Training Step: 2550...  Training loss: 1.7702...  0.0797 sec/batch
Epoch: 1/20...  Training Step: 2600...  Training loss: 1.7222...  0.0734 sec/batch
Epoch: 1/20...  Training Step: 2650...  Training loss: 1.9191...  0.0869 sec/batch
Epoch: 1/20...  Training Step: 2700...  Training loss: 1.8327...  0.0758 sec/batch
Epoch: 1/20...  Training Step: 2750...  Training loss: 1.6458...  0.0717 sec/batch
Epoch: 1/20...  Training Step: 2800...  Training loss: 1.6423...  0.0865 sec/batch
Epoch: 1/20...  Training Step: 2850...  Training loss: 1.8341...  0.0778 sec/batch
Epoch: 1/20...  Training Step: 2900...  Training loss: 1.6204...  0.0993 sec/batch
Epoch: 1/20...  Training Step: 2950...  Training loss: 1.5896...  0.1127 sec/batch
Epoch: 1/20...  Training Step: 3000...  Training loss: 1.7598...  0.1231 sec/batch
Epoch: 1/20...  Training Step: 3050...  Training loss: 1.8506...  0.1049 sec/batch
Epoch: 1/20...  Training Step: 3100...  Training loss: 1.6673...  0.1162 sec/batch
Epoch: 1/20...  Training Step: 3150...  Training loss: 1.5953...  0.0973 sec/batch
Epoch: 1/20...  Training Step: 3200...  Training loss: 1.8086...  0.0736 sec/batch
Epoch: 1/20...  Training Step: 3250...  Training loss: 1.7185...  0.1560 sec/batch
Epoch: 1/20...  Training Step: 3300...  Training loss: 1.8194...  0.1111 sec/batch
Epoch: 1/20...  Training Step: 3350...  Training loss: 1.5989...  0.0863 sec/batch
Epoch: 1/20...  Training Step: 3400...  Training loss: 1.6702...  0.1182 sec/batch
Epoch: 1/20...  Training Step: 3450...  Training loss: 1.6921...  0.0906 sec/batch
Epoch: 1/20...  Training Step: 3500...  Training loss: 1.6991...  0.1485 sec/batch
Epoch: 1/20...  Training Step: 3550...  Training loss: 1.7895...  0.1362 sec/batch
Epoch: 1/20...  Training Step: 3600...  Training loss: 1.7777...  0.1830 sec/batch
Epoch: 1/20...  Training Step: 3650...  Training loss: 1.8947...  0.1051 sec/batch
Epoch: 1/20...  Training Step: 3700...  Training loss: 1.6729...  0.1078 sec/batch
Epoch: 1/20...  Training Step: 3750...  Training loss: 1.8095...  0.0987 sec/batch
Epoch: 1/20...  Training Step: 3800...  Training loss: 1.7446...  0.0986 sec/batch
Epoch: 1/20...  Training Step: 3850...  Training loss: 1.7131...  0.0987 sec/batch
Epoch: 1/20...  Training Step: 3900...  Training loss: 1.8149...  0.0957 sec/batch
Epoch: 1/20...  Training Step: 3950...  Training loss: 1.6854...  0.1104 sec/batch
Epoch: 2/20...  Training Step: 4000...  Training loss: 1.6856...  0.1065 sec/batch
Epoch: 2/20...  Training Step: 4050...  Training loss: 1.7307...  0.0778 sec/batch
Epoch: 2/20...  Training Step: 4100...  Training loss: 1.6526...  0.0920 sec/batch
Epoch: 2/20...  Training Step: 4150...  Training loss: 1.5635...  0.1025 sec/batch
Epoch: 2/20...  Training Step: 4200...  Training loss: 1.6581...  0.1270 sec/batch
Epoch: 2/20...  Training Step: 4250...  Training loss: 1.7660...  0.1233 sec/batch
Epoch: 2/20...  Training Step: 4300...  Training loss: 1.7417...  0.1003 sec/batch
Epoch: 2/20...  Training Step: 4350...  Training loss: 1.7011...  0.0930 sec/batch
Epoch: 2/20...  Training Step: 4400...  Training loss: 1.6249...  0.1128 sec/batch
Epoch: 2/20...  Training Step: 4450...  Training loss: 1.7398...  0.0936 sec/batch
Epoch: 2/20...  Training Step: 4500...  Training loss: 1.7439...  0.1068 sec/batch
Epoch: 2/20...  Training Step: 4550...  Training loss: 1.8637...  0.1134 sec/batch
Epoch: 2/20...  Training Step: 4600...  Training loss: 1.7691...  0.1422 sec/batch
Epoch: 2/20...  Training Step: 4650...  Training loss: 1.8814...  0.1075 sec/batch
Epoch: 2/20...  Training Step: 4700...  Training loss: 1.6264...  0.0831 sec/batch
Epoch: 2/20...  Training Step: 4750...  Training loss: 1.7554...  0.0896 sec/batch
Epoch: 2/20...  Training Step: 4800...  Training loss: 1.5712...  0.1397 sec/batch
Epoch: 2/20...  Training Step: 4850...  Training loss: 1.6104...  0.0933 sec/batch
Epoch: 2/20...  Training Step: 4900...  Training loss: 1.7786...  0.0979 sec/batch
Epoch: 2/20...  Training Step: 4950...  Training loss: 1.5826...  0.0746 sec/batch
Epoch: 2/20...  Training Step: 5000...  Training loss: 1.7298...  0.0909 sec/batch
Epoch: 2/20...  Training Step: 5050...  Training loss: 1.5863...  0.0750 sec/batch
Epoch: 2/20...  Training Step: 5100...  Training loss: 1.5854...  0.0841 sec/batch
Epoch: 2/20...  Training Step: 5150...  Training loss: 1.6731...  0.0797 sec/batch
Epoch: 2/20...  Training Step: 5200...  Training loss: 1.7486...  0.0994 sec/batch
Epoch: 2/20...  Training Step: 5250...  Training loss: 1.6027...  0.0896 sec/batch
Epoch: 2/20...  Training Step: 5300...  Training loss: 1.8483...  0.1041 sec/batch
Epoch: 2/20...  Training Step: 5350...  Training loss: 1.6981...  0.0980 sec/batch
Epoch: 2/20...  Training Step: 5400...  Training loss: 1.7340...  0.1030 sec/batch
Epoch: 2/20...  Training Step: 5450...  Training loss: 1.7671...  0.0908 sec/batch
Epoch: 2/20...  Training Step: 5500...  Training loss: 1.8226...  0.0849 sec/batch
Epoch: 2/20...  Training Step: 5550...  Training loss: 1.6329...  0.0869 sec/batch
Epoch: 2/20...  Training Step: 5600...  Training loss: 1.7875...  0.0803 sec/batch
Epoch: 2/20...  Training Step: 5650...  Training loss: 1.6364...  0.0968 sec/batch
Epoch: 2/20...  Training Step: 5700...  Training loss: 1.5620...  0.0787 sec/batch
Epoch: 2/20...  Training Step: 5750...  Training loss: 1.6333...  0.0889 sec/batch
Epoch: 2/20...  Training Step: 5800...  Training loss: 1.6394...  0.0938 sec/batch
Epoch: 2/20...  Training Step: 5850...  Training loss: 1.7787...  0.1022 sec/batch
Epoch: 2/20...  Training Step: 5900...  Training loss: 1.7069...  0.0872 sec/batch
Epoch: 2/20...  Training Step: 5950...  Training loss: 1.6597...  0.0861 sec/batch
Epoch: 2/20...  Training Step: 6000...  Training loss: 1.5895...  0.0734 sec/batch
Epoch: 2/20...  Training Step: 6050...  Training loss: 1.6360...  0.0778 sec/batch
Epoch: 2/20...  Training Step: 6100...  Training loss: 1.7429...  0.0791 sec/batch
Epoch: 2/20...  Training Step: 6150...  Training loss: 1.7000...  0.1017 sec/batch
Epoch: 2/20...  Training Step: 6200...  Training loss: 1.6729...  0.0711 sec/batch
Epoch: 2/20...  Training Step: 6250...  Training loss: 1.6362...  0.0805 sec/batch
Epoch: 2/20...  Training Step: 6300...  Training loss: 1.5817...  0.1046 sec/batch
Epoch: 2/20...  Training Step: 6350...  Training loss: 1.7030...  0.0831 sec/batch
Epoch: 2/20...  Training Step: 6400...  Training loss: 1.6369...  0.0993 sec/batch
Epoch: 2/20...  Training Step: 6450...  Training loss: 1.7318...  0.0916 sec/batch
Epoch: 2/20...  Training Step: 6500...  Training loss: 1.6383...  0.0904 sec/batch
Epoch: 2/20...  Training Step: 6550...  Training loss: 1.7632...  0.1019 sec/batch
Epoch: 2/20...  Training Step: 6600...  Training loss: 1.8060...  0.0975 sec/batch
Epoch: 2/20...  Training Step: 6650...  Training loss: 1.5034...  0.1064 sec/batch
Epoch: 2/20...  Training Step: 6700...  Training loss: 1.6139...  0.0781 sec/batch
Epoch: 2/20...  Training Step: 6750...  Training loss: 1.6378...  0.0732 sec/batch
Epoch: 2/20...  Training Step: 6800...  Training loss: 1.7362...  0.0959 sec/batch
Epoch: 2/20...  Training Step: 6850...  Training loss: 1.5682...  0.0977 sec/batch
Epoch: 2/20...  Training Step: 6900...  Training loss: 1.5746...  0.0865 sec/batch
Epoch: 2/20...  Training Step: 6950...  Training loss: 1.9023...  0.0740 sec/batch
Epoch: 2/20...  Training Step: 7000...  Training loss: 1.5752...  0.0812 sec/batch
Epoch: 2/20...  Training Step: 7050...  Training loss: 1.6171...  0.0787 sec/batch
Epoch: 2/20...  Training Step: 7100...  Training loss: 1.5970...  0.0910 sec/batch
Epoch: 2/20...  Training Step: 7150...  Training loss: 1.5820...  0.0783 sec/batch
Epoch: 2/20...  Training Step: 7200...  Training loss: 1.7329...  0.0959 sec/batch
Epoch: 2/20...  Training Step: 7250...  Training loss: 1.4948...  0.0821 sec/batch
Epoch: 2/20...  Training Step: 7300...  Training loss: 1.7378...  0.0819 sec/batch
Epoch: 2/20...  Training Step: 7350...  Training loss: 1.5604...  0.1006 sec/batch
Epoch: 2/20...  Training Step: 7400...  Training loss: 1.4981...  0.0790 sec/batch
Epoch: 2/20...  Training Step: 7450...  Training loss: 1.4596...  0.0949 sec/batch
Epoch: 2/20...  Training Step: 7500...  Training loss: 1.5234...  0.0939 sec/batch
Epoch: 2/20...  Training Step: 7550...  Training loss: 1.6155...  0.0909 sec/batch
Epoch: 2/20...  Training Step: 7600...  Training loss: 1.6868...  0.1081 sec/batch
Epoch: 2/20...  Training Step: 7650...  Training loss: 1.8391...  0.0746 sec/batch
Epoch: 2/20...  Training Step: 7700...  Training loss: 1.8426...  0.0910 sec/batch
Epoch: 2/20...  Training Step: 7750...  Training loss: 1.9667...  0.0900 sec/batch
Epoch: 2/20...  Training Step: 7800...  Training loss: 1.7286...  0.0767 sec/batch
Epoch: 2/20...  Training Step: 7850...  Training loss: 1.6956...  0.1056 sec/batch
Epoch: 2/20...  Training Step: 7900...  Training loss: 1.7824...  0.0764 sec/batch
Epoch: 3/20...  Training Step: 7950...  Training loss: 1.6794...  0.0875 sec/batch
Epoch: 3/20...  Training Step: 8000...  Training loss: 1.6412...  0.0767 sec/batch
Epoch: 3/20...  Training Step: 8050...  Training loss: 1.7181...  0.0891 sec/batch
Epoch: 3/20...  Training Step: 8100...  Training loss: 1.8203...  0.0992 sec/batch
Epoch: 3/20...  Training Step: 8150...  Training loss: 1.6394...  0.0765 sec/batch
Epoch: 3/20...  Training Step: 8200...  Training loss: 1.6109...  0.0737 sec/batch
Epoch: 3/20...  Training Step: 8250...  Training loss: 1.7316...  0.0788 sec/batch
Epoch: 3/20...  Training Step: 8300...  Training loss: 1.7340...  0.0815 sec/batch
Epoch: 3/20...  Training Step: 8350...  Training loss: 1.7087...  0.0716 sec/batch
Epoch: 3/20...  Training Step: 8400...  Training loss: 1.7574...  0.0978 sec/batch
Epoch: 3/20...  Training Step: 8450...  Training loss: 1.7552...  0.0744 sec/batch
Epoch: 3/20...  Training Step: 8500...  Training loss: 1.6684...  0.0842 sec/batch
Epoch: 3/20...  Training Step: 8550...  Training loss: 1.6157...  0.0867 sec/batch
Epoch: 3/20...  Training Step: 8600...  Training loss: 1.6179...  0.0757 sec/batch
Epoch: 3/20...  Training Step: 8650...  Training loss: 1.6648...  0.0814 sec/batch
Epoch: 3/20...  Training Step: 8700...  Training loss: 1.6442...  0.0840 sec/batch
Epoch: 3/20...  Training Step: 8750...  Training loss: 1.5586...  0.0925 sec/batch
Epoch: 3/20...  Training Step: 8800...  Training loss: 1.8144...  0.0885 sec/batch
Epoch: 3/20...  Training Step: 8850...  Training loss: 1.6464...  0.0945 sec/batch
Epoch: 3/20...  Training Step: 8900...  Training loss: 1.6989...  0.0718 sec/batch
Epoch: 3/20...  Training Step: 8950...  Training loss: 1.7435...  0.0756 sec/batch
Epoch: 3/20...  Training Step: 9000...  Training loss: 1.5654...  0.0748 sec/batch
Epoch: 3/20...  Training Step: 9050...  Training loss: 1.5484...  0.0801 sec/batch
Epoch: 3/20...  Training Step: 9100...  Training loss: 1.4785...  0.0908 sec/batch
Epoch: 3/20...  Training Step: 9150...  Training loss: 1.6143...  0.0923 sec/batch
Epoch: 3/20...  Training Step: 9200...  Training loss: 1.5974...  0.0874 sec/batch
Epoch: 3/20...  Training Step: 9250...  Training loss: 1.7388...  0.0786 sec/batch
Epoch: 3/20...  Training Step: 9300...  Training loss: 1.5446...  0.0790 sec/batch
Epoch: 3/20...  Training Step: 9350...  Training loss: 1.6712...  0.0993 sec/batch
Epoch: 3/20...  Training Step: 9400...  Training loss: 1.7105...  0.0814 sec/batch
Epoch: 3/20...  Training Step: 9450...  Training loss: 1.6057...  0.0886 sec/batch
Epoch: 3/20...  Training Step: 9500...  Training loss: 1.6898...  0.3614 sec/batch
Epoch: 3/20...  Training Step: 9550...  Training loss: 1.7313...  0.0988 sec/batch
Epoch: 3/20...  Training Step: 9600...  Training loss: 1.5991...  0.1520 sec/batch
Epoch: 3/20...  Training Step: 9650...  Training loss: 1.6236...  0.1014 sec/batch
Epoch: 3/20...  Training Step: 9700...  Training loss: 1.5599...  0.1372 sec/batch
Epoch: 3/20...  Training Step: 9750...  Training loss: 1.4180...  0.1770 sec/batch
Epoch: 3/20...  Training Step: 9800...  Training loss: 1.6951...  0.0787 sec/batch
Epoch: 3/20...  Training Step: 9850...  Training loss: 1.5640...  0.0934 sec/batch
Epoch: 3/20...  Training Step: 9900...  Training loss: 1.6818...  0.0949 sec/batch
Epoch: 3/20...  Training Step: 9950...  Training loss: 1.6847...  0.0941 sec/batch
Epoch: 3/20...  Training Step: 10000...  Training loss: 1.4928...  0.0860 sec/batch
Epoch: 3/20...  Training Step: 10050...  Training loss: 1.6388...  0.0795 sec/batch
Epoch: 3/20...  Training Step: 10100...  Training loss: 1.6759...  0.0766 sec/batch
Epoch: 3/20...  Training Step: 10150...  Training loss: 1.7183...  0.2075 sec/batch
Epoch: 3/20...  Training Step: 10200...  Training loss: 1.8169...  0.0908 sec/batch
Epoch: 3/20...  Training Step: 10250...  Training loss: 1.6602...  0.0961 sec/batch
Epoch: 3/20...  Training Step: 10300...  Training loss: 1.7933...  0.0917 sec/batch
Epoch: 3/20...  Training Step: 10350...  Training loss: 1.5900...  0.0988 sec/batch
Epoch: 3/20...  Training Step: 10400...  Training loss: 1.7477...  0.1217 sec/batch
Epoch: 3/20...  Training Step: 10450...  Training loss: 1.6281...  0.0770 sec/batch
Epoch: 3/20...  Training Step: 10500...  Training loss: 1.4156...  0.0986 sec/batch
Epoch: 3/20...  Training Step: 10550...  Training loss: 1.7025...  0.0965 sec/batch
Epoch: 3/20...  Training Step: 10600...  Training loss: 1.7854...  0.1115 sec/batch
Epoch: 3/20...  Training Step: 10650...  Training loss: 1.6032...  0.0869 sec/batch
Epoch: 3/20...  Training Step: 10700...  Training loss: 1.6644...  0.0870 sec/batch
Epoch: 3/20...  Training Step: 10750...  Training loss: 1.7093...  0.0869 sec/batch
Epoch: 3/20...  Training Step: 10800...  Training loss: 1.5946...  0.0765 sec/batch
Epoch: 3/20...  Training Step: 10850...  Training loss: 1.6031...  0.0762 sec/batch
Epoch: 3/20...  Training Step: 10900...  Training loss: 1.6952...  0.0856 sec/batch
Epoch: 3/20...  Training Step: 10950...  Training loss: 1.7284...  0.0727 sec/batch
Epoch: 3/20...  Training Step: 11000...  Training loss: 1.5816...  0.0809 sec/batch
Epoch: 3/20...  Training Step: 11050...  Training loss: 1.6427...  0.0863 sec/batch
Epoch: 3/20...  Training Step: 11100...  Training loss: 1.5230...  0.0946 sec/batch
Epoch: 3/20...  Training Step: 11150...  Training loss: 1.5090...  0.1142 sec/batch
Epoch: 3/20...  Training Step: 11200...  Training loss: 1.5492...  0.1061 sec/batch
Epoch: 3/20...  Training Step: 11250...  Training loss: 1.6195...  0.0797 sec/batch
Epoch: 3/20...  Training Step: 11300...  Training loss: 1.5360...  0.0901 sec/batch
Epoch: 3/20...  Training Step: 11350...  Training loss: 1.6970...  0.0901 sec/batch
Epoch: 3/20...  Training Step: 11400...  Training loss: 1.5737...  0.0971 sec/batch
Epoch: 3/20...  Training Step: 11450...  Training loss: 1.5928...  0.0957 sec/batch
Epoch: 3/20...  Training Step: 11500...  Training loss: 1.6114...  0.1138 sec/batch
Epoch: 3/20...  Training Step: 11550...  Training loss: 1.6818...  0.1008 sec/batch
Epoch: 3/20...  Training Step: 11600...  Training loss: 1.7089...  0.0886 sec/batch
Epoch: 3/20...  Training Step: 11650...  Training loss: 1.6205...  0.0833 sec/batch
Epoch: 3/20...  Training Step: 11700...  Training loss: 1.5619...  0.0758 sec/batch
Epoch: 3/20...  Training Step: 11750...  Training loss: 1.7112...  0.0890 sec/batch
Epoch: 3/20...  Training Step: 11800...  Training loss: 1.7122...  0.1067 sec/batch
Epoch: 3/20...  Training Step: 11850...  Training loss: 1.9889...  0.1013 sec/batch
Epoch: 3/20...  Training Step: 11900...  Training loss: 1.6851...  0.0876 sec/batch
Epoch: 4/20...  Training Step: 11950...  Training loss: 1.7172...  0.0845 sec/batch
Epoch: 4/20...  Training Step: 12000...  Training loss: 1.6953...  0.0887 sec/batch
Epoch: 4/20...  Training Step: 12050...  Training loss: 1.6057...  0.1075 sec/batch
Epoch: 4/20...  Training Step: 12100...  Training loss: 1.5663...  0.1218 sec/batch
Epoch: 4/20...  Training Step: 12150...  Training loss: 1.6516...  0.0798 sec/batch
Epoch: 4/20...  Training Step: 12200...  Training loss: 1.5765...  0.0973 sec/batch
Epoch: 4/20...  Training Step: 12250...  Training loss: 1.6334...  0.0733 sec/batch
Epoch: 4/20...  Training Step: 12300...  Training loss: 1.5896...  0.0749 sec/batch
Epoch: 4/20...  Training Step: 12350...  Training loss: 1.7039...  0.0906 sec/batch
Epoch: 4/20...  Training Step: 12400...  Training loss: 1.6553...  0.0783 sec/batch
Epoch: 4/20...  Training Step: 12450...  Training loss: 1.4370...  0.0889 sec/batch
Epoch: 4/20...  Training Step: 12500...  Training loss: 1.7787...  0.0848 sec/batch
Epoch: 4/20...  Training Step: 12550...  Training loss: 1.5061...  0.0927 sec/batch
Epoch: 4/20...  Training Step: 12600...  Training loss: 1.5997...  0.0840 sec/batch
Epoch: 4/20...  Training Step: 12650...  Training loss: 1.5346...  0.0744 sec/batch
Epoch: 4/20...  Training Step: 12700...  Training loss: 1.5538...  0.1223 sec/batch
Epoch: 4/20...  Training Step: 12750...  Training loss: 1.5904...  0.1434 sec/batch
Epoch: 4/20...  Training Step: 12800...  Training loss: 1.6283...  0.0790 sec/batch
Epoch: 4/20...  Training Step: 12850...  Training loss: 1.5003...  0.1173 sec/batch
Epoch: 4/20...  Training Step: 12900...  Training loss: 1.4716...  0.0810 sec/batch
Epoch: 4/20...  Training Step: 12950...  Training loss: 1.5468...  0.0828 sec/batch
Epoch: 4/20...  Training Step: 13000...  Training loss: 1.7562...  0.0950 sec/batch
Epoch: 4/20...  Training Step: 13050...  Training loss: 1.7370...  0.0782 sec/batch
Epoch: 4/20...  Training Step: 13100...  Training loss: 1.5227...  0.0797 sec/batch
Epoch: 4/20...  Training Step: 13150...  Training loss: 1.5434...  0.0911 sec/batch
Epoch: 4/20...  Training Step: 13200...  Training loss: 1.7194...  0.0856 sec/batch
Epoch: 4/20...  Training Step: 13250...  Training loss: 1.5616...  0.1049 sec/batch
Epoch: 4/20...  Training Step: 13300...  Training loss: 1.5603...  0.0705 sec/batch
Epoch: 4/20...  Training Step: 13350...  Training loss: 1.5274...  0.0954 sec/batch
Epoch: 4/20...  Training Step: 13400...  Training loss: 1.6354...  0.0996 sec/batch
Epoch: 4/20...  Training Step: 13450...  Training loss: 1.6451...  0.0697 sec/batch
Epoch: 4/20...  Training Step: 13500...  Training loss: 1.6113...  0.0969 sec/batch
Epoch: 4/20...  Training Step: 13550...  Training loss: 1.6739...  0.0923 sec/batch
Epoch: 4/20...  Training Step: 13600...  Training loss: 1.5817...  0.0954 sec/batch
Epoch: 4/20...  Training Step: 13650...  Training loss: 1.6270...  0.0771 sec/batch
Epoch: 4/20...  Training Step: 13700...  Training loss: 1.5857...  0.0745 sec/batch
Epoch: 4/20...  Training Step: 13750...  Training loss: 1.6121...  0.0818 sec/batch
Epoch: 4/20...  Training Step: 13800...  Training loss: 1.6075...  0.0893 sec/batch
Epoch: 4/20...  Training Step: 13850...  Training loss: 1.8447...  0.0898 sec/batch
Epoch: 4/20...  Training Step: 13900...  Training loss: 1.5798...  0.0963 sec/batch
Epoch: 4/20...  Training Step: 13950...  Training loss: 1.6464...  0.0897 sec/batch
Epoch: 4/20...  Training Step: 14000...  Training loss: 1.5325...  0.0784 sec/batch
Epoch: 4/20...  Training Step: 14050...  Training loss: 1.5516...  0.0806 sec/batch
Epoch: 4/20...  Training Step: 14100...  Training loss: 1.5421...  0.0838 sec/batch
Epoch: 4/20...  Training Step: 14150...  Training loss: 1.8151...  0.0996 sec/batch
Epoch: 4/20...  Training Step: 14200...  Training loss: 1.5766...  0.0875 sec/batch
Epoch: 4/20...  Training Step: 14250...  Training loss: 1.7361...  0.0749 sec/batch
Epoch: 4/20...  Training Step: 14300...  Training loss: 1.6325...  0.0711 sec/batch
Epoch: 4/20...  Training Step: 14350...  Training loss: 1.5686...  0.0800 sec/batch
Epoch: 4/20...  Training Step: 14400...  Training loss: 1.6178...  0.0793 sec/batch
Epoch: 4/20...  Training Step: 14450...  Training loss: 1.6965...  0.0822 sec/batch
Epoch: 4/20...  Training Step: 14500...  Training loss: 1.6766...  0.0695 sec/batch
Epoch: 4/20...  Training Step: 14550...  Training loss: 1.5583...  0.1027 sec/batch
Epoch: 4/20...  Training Step: 14600...  Training loss: 1.7580...  0.0847 sec/batch
Epoch: 4/20...  Training Step: 14650...  Training loss: 1.5452...  0.0784 sec/batch
Epoch: 4/20...  Training Step: 14700...  Training loss: 1.5275...  0.0763 sec/batch
Epoch: 4/20...  Training Step: 14750...  Training loss: 1.6009...  0.0775 sec/batch
Epoch: 4/20...  Training Step: 14800...  Training loss: 1.4720...  0.0900 sec/batch
Epoch: 4/20...  Training Step: 14850...  Training loss: 1.5884...  0.0821 sec/batch
Epoch: 4/20...  Training Step: 14900...  Training loss: 1.5574...  0.0964 sec/batch
Epoch: 4/20...  Training Step: 14950...  Training loss: 1.6721...  0.0775 sec/batch
Epoch: 4/20...  Training Step: 15000...  Training loss: 1.5798...  0.0747 sec/batch
Epoch: 4/20...  Training Step: 15050...  Training loss: 1.7601...  0.0917 sec/batch
Epoch: 4/20...  Training Step: 15100...  Training loss: 1.5202...  0.0928 sec/batch
Epoch: 4/20...  Training Step: 15150...  Training loss: 1.5794...  0.0885 sec/batch
Epoch: 4/20...  Training Step: 15200...  Training loss: 1.7028...  0.0835 sec/batch
Epoch: 4/20...  Training Step: 15250...  Training loss: 1.5549...  0.0840 sec/batch
Epoch: 4/20...  Training Step: 15300...  Training loss: 1.5742...  0.0770 sec/batch
Epoch: 4/20...  Training Step: 15350...  Training loss: 1.6728...  0.0947 sec/batch
Epoch: 4/20...  Training Step: 15400...  Training loss: 1.7407...  0.0733 sec/batch
Epoch: 4/20...  Training Step: 15450...  Training loss: 1.5881...  0.0846 sec/batch
Epoch: 4/20...  Training Step: 15500...  Training loss: 1.5219...  0.1014 sec/batch
Epoch: 4/20...  Training Step: 15550...  Training loss: 1.5556...  0.0785 sec/batch
Epoch: 4/20...  Training Step: 15600...  Training loss: 1.5898...  0.1128 sec/batch
Epoch: 4/20...  Training Step: 15650...  Training loss: 1.6312...  0.0952 sec/batch
Epoch: 4/20...  Training Step: 15700...  Training loss: 1.5292...  0.0908 sec/batch
Epoch: 4/20...  Training Step: 15750...  Training loss: 1.6945...  0.0954 sec/batch
Epoch: 4/20...  Training Step: 15800...  Training loss: 1.7280...  0.0890 sec/batch
Epoch: 4/20...  Training Step: 15850...  Training loss: 1.6063...  0.0733 sec/batch
Epoch: 5/20...  Training Step: 15900...  Training loss: 1.7385...  0.0792 sec/batch
Epoch: 5/20...  Training Step: 15950...  Training loss: 1.5475...  0.0766 sec/batch
Epoch: 5/20...  Training Step: 16000...  Training loss: 1.5115...  0.0776 sec/batch
Epoch: 5/20...  Training Step: 16050...  Training loss: 1.6002...  0.0959 sec/batch
Epoch: 5/20...  Training Step: 16100...  Training loss: 1.6011...  0.0804 sec/batch
Epoch: 5/20...  Training Step: 16150...  Training loss: 1.5730...  0.0995 sec/batch
Epoch: 5/20...  Training Step: 16200...  Training loss: 1.6419...  0.0834 sec/batch
Epoch: 5/20...  Training Step: 16250...  Training loss: 1.6817...  0.1025 sec/batch
Epoch: 5/20...  Training Step: 16300...  Training loss: 1.6162...  0.0762 sec/batch
Epoch: 5/20...  Training Step: 16350...  Training loss: 1.6558...  0.0989 sec/batch
Epoch: 5/20...  Training Step: 16400...  Training loss: 1.5497...  0.0840 sec/batch
Epoch: 5/20...  Training Step: 16450...  Training loss: 1.5893...  0.1082 sec/batch
Epoch: 5/20...  Training Step: 16500...  Training loss: 1.4194...  0.0988 sec/batch
Epoch: 5/20...  Training Step: 16550...  Training loss: 1.6069...  0.0769 sec/batch
Epoch: 5/20...  Training Step: 16600...  Training loss: 1.6264...  0.0763 sec/batch
Epoch: 5/20...  Training Step: 16650...  Training loss: 1.5933...  0.1063 sec/batch
Epoch: 5/20...  Training Step: 16700...  Training loss: 1.6155...  0.1039 sec/batch
Epoch: 5/20...  Training Step: 16750...  Training loss: 1.5995...  0.0731 sec/batch
Epoch: 5/20...  Training Step: 16800...  Training loss: 1.5220...  0.0907 sec/batch
Epoch: 5/20...  Training Step: 16850...  Training loss: 1.5326...  0.0858 sec/batch
Epoch: 5/20...  Training Step: 16900...  Training loss: 1.4057...  0.0731 sec/batch
Epoch: 5/20...  Training Step: 16950...  Training loss: 1.5110...  0.0836 sec/batch
Epoch: 5/20...  Training Step: 17000...  Training loss: 1.3836...  0.0974 sec/batch
Epoch: 5/20...  Training Step: 17050...  Training loss: 1.5358...  0.0944 sec/batch
Epoch: 5/20...  Training Step: 17100...  Training loss: 1.3823...  0.0868 sec/batch
Epoch: 5/20...  Training Step: 17150...  Training loss: 1.5705...  0.0776 sec/batch
Epoch: 5/20...  Training Step: 17200...  Training loss: 1.6124...  0.0960 sec/batch
Epoch: 5/20...  Training Step: 17250...  Training loss: 1.5769...  0.0949 sec/batch
Epoch: 5/20...  Training Step: 17300...  Training loss: 1.5352...  0.0815 sec/batch
Epoch: 5/20...  Training Step: 17350...  Training loss: 1.5330...  0.0788 sec/batch
Epoch: 5/20...  Training Step: 17400...  Training loss: 1.5992...  0.0811 sec/batch
Epoch: 5/20...  Training Step: 17450...  Training loss: 1.5935...  0.0770 sec/batch
Epoch: 5/20...  Training Step: 17500...  Training loss: 1.6403...  0.1097 sec/batch
Epoch: 5/20...  Training Step: 17550...  Training loss: 1.6861...  0.0911 sec/batch
Epoch: 5/20...  Training Step: 17600...  Training loss: 1.5259...  0.0813 sec/batch
Epoch: 5/20...  Training Step: 17650...  Training loss: 1.5710...  0.0873 sec/batch
Epoch: 5/20...  Training Step: 17700...  Training loss: 1.6125...  0.0707 sec/batch
Epoch: 5/20...  Training Step: 17750...  Training loss: 1.4601...  0.0960 sec/batch
Epoch: 5/20...  Training Step: 17800...  Training loss: 1.6135...  0.0946 sec/batch
Epoch: 5/20...  Training Step: 17850...  Training loss: 1.5322...  0.1000 sec/batch
Epoch: 5/20...  Training Step: 17900...  Training loss: 1.4918...  0.0950 sec/batch
Epoch: 5/20...  Training Step: 17950...  Training loss: 1.4961...  0.0913 sec/batch
Epoch: 5/20...  Training Step: 18000...  Training loss: 1.3463...  0.0742 sec/batch
Epoch: 5/20...  Training Step: 18050...  Training loss: 1.5099...  0.1017 sec/batch
Epoch: 5/20...  Training Step: 18100...  Training loss: 1.6074...  0.0831 sec/batch
Epoch: 5/20...  Training Step: 18150...  Training loss: 1.4818...  0.1156 sec/batch
Epoch: 5/20...  Training Step: 18200...  Training loss: 1.5491...  0.1028 sec/batch
Epoch: 5/20...  Training Step: 18250...  Training loss: 1.5235...  0.0788 sec/batch
Epoch: 5/20...  Training Step: 18300...  Training loss: 1.7310...  0.0989 sec/batch
Epoch: 5/20...  Training Step: 18350...  Training loss: 1.5857...  0.0833 sec/batch
Epoch: 5/20...  Training Step: 18400...  Training loss: 1.6156...  0.0929 sec/batch
Epoch: 5/20...  Training Step: 18450...  Training loss: 1.5006...  0.0818 sec/batch
Epoch: 5/20...  Training Step: 18500...  Training loss: 1.4500...  0.0784 sec/batch
Epoch: 5/20...  Training Step: 18550...  Training loss: 1.5999...  0.0902 sec/batch
Epoch: 5/20...  Training Step: 18600...  Training loss: 1.4849...  0.1070 sec/batch
Epoch: 5/20...  Training Step: 18650...  Training loss: 1.6307...  0.0859 sec/batch
Epoch: 5/20...  Training Step: 18700...  Training loss: 1.6703...  0.0956 sec/batch
Epoch: 5/20...  Training Step: 18750...  Training loss: 1.5738...  0.0806 sec/batch
Epoch: 5/20...  Training Step: 18800...  Training loss: 1.6527...  0.0943 sec/batch
Epoch: 5/20...  Training Step: 18850...  Training loss: 1.4661...  0.0796 sec/batch
Epoch: 5/20...  Training Step: 18900...  Training loss: 1.6544...  0.0942 sec/batch
Epoch: 5/20...  Training Step: 18950...  Training loss: 1.5432...  0.0955 sec/batch
Epoch: 5/20...  Training Step: 19000...  Training loss: 1.5296...  0.0811 sec/batch
Epoch: 5/20...  Training Step: 19050...  Training loss: 1.5688...  0.0746 sec/batch
Epoch: 5/20...  Training Step: 19100...  Training loss: 1.5714...  0.0862 sec/batch
Epoch: 5/20...  Training Step: 19150...  Training loss: 1.6118...  0.1007 sec/batch
Epoch: 5/20...  Training Step: 19200...  Training loss: 1.5678...  0.0997 sec/batch
Epoch: 5/20...  Training Step: 19250...  Training loss: 1.4726...  0.1036 sec/batch
Epoch: 5/20...  Training Step: 19300...  Training loss: 1.6758...  0.1086 sec/batch
Epoch: 5/20...  Training Step: 19350...  Training loss: 1.5897...  0.0789 sec/batch
Epoch: 5/20...  Training Step: 19400...  Training loss: 1.5576...  0.0806 sec/batch
Epoch: 5/20...  Training Step: 19450...  Training loss: 1.3073...  0.1230 sec/batch
Epoch: 5/20...  Training Step: 19500...  Training loss: 1.5237...  0.0789 sec/batch
Epoch: 5/20...  Training Step: 19550...  Training loss: 1.5836...  0.1017 sec/batch
Epoch: 5/20...  Training Step: 19600...  Training loss: 1.5293...  0.1026 sec/batch
Epoch: 5/20...  Training Step: 19650...  Training loss: 1.5953...  0.0928 sec/batch
Epoch: 5/20...  Training Step: 19700...  Training loss: 1.8602...  0.0933 sec/batch
Epoch: 5/20...  Training Step: 19750...  Training loss: 1.6971...  0.0731 sec/batch
Epoch: 5/20...  Training Step: 19800...  Training loss: 1.8591...  0.0850 sec/batch
Epoch: 5/20...  Training Step: 19850...  Training loss: 1.8379...  0.0951 sec/batch
Epoch: 6/20...  Training Step: 19900...  Training loss: 1.6833...  0.1160 sec/batch
Epoch: 6/20...  Training Step: 19950...  Training loss: 1.5844...  0.0995 sec/batch
Epoch: 6/20...  Training Step: 20000...  Training loss: 1.3810...  0.0943 sec/batch
Epoch: 6/20...  Training Step: 20050...  Training loss: 1.5177...  0.1004 sec/batch
Epoch: 6/20...  Training Step: 20100...  Training loss: 1.5482...  0.0915 sec/batch
Epoch: 6/20...  Training Step: 20150...  Training loss: 1.4564...  0.0766 sec/batch
Epoch: 6/20...  Training Step: 20200...  Training loss: 1.5526...  0.1109 sec/batch
Epoch: 6/20...  Training Step: 20250...  Training loss: 1.6006...  0.0791 sec/batch
Epoch: 6/20...  Training Step: 20300...  Training loss: 1.6793...  0.0820 sec/batch
Epoch: 6/20...  Training Step: 20350...  Training loss: 1.6225...  0.0923 sec/batch
Epoch: 6/20...  Training Step: 20400...  Training loss: 1.4183...  0.0811 sec/batch
Epoch: 6/20...  Training Step: 20450...  Training loss: 1.4983...  0.0984 sec/batch
Epoch: 6/20...  Training Step: 20500...  Training loss: 1.4047...  0.0770 sec/batch
Epoch: 6/20...  Training Step: 20550...  Training loss: 1.4601...  0.0819 sec/batch
Epoch: 6/20...  Training Step: 20600...  Training loss: 1.5404...  0.0709 sec/batch
Epoch: 6/20...  Training Step: 20650...  Training loss: 1.5828...  0.1108 sec/batch
Epoch: 6/20...  Training Step: 20700...  Training loss: 1.6994...  0.0979 sec/batch
Epoch: 6/20...  Training Step: 20750...  Training loss: 1.5974...  0.0833 sec/batch
Epoch: 6/20...  Training Step: 20800...  Training loss: 1.5593...  0.0979 sec/batch
Epoch: 6/20...  Training Step: 20850...  Training loss: 1.5273...  0.0941 sec/batch
Epoch: 6/20...  Training Step: 20900...  Training loss: 1.5725...  0.0868 sec/batch
Epoch: 6/20...  Training Step: 20950...  Training loss: 1.5729...  0.0864 sec/batch
Epoch: 6/20...  Training Step: 21000...  Training loss: 1.5493...  0.0730 sec/batch
Epoch: 6/20...  Training Step: 21050...  Training loss: 1.5124...  0.0992 sec/batch
Epoch: 6/20...  Training Step: 21100...  Training loss: 1.3825...  0.0771 sec/batch
Epoch: 6/20...  Training Step: 21150...  Training loss: 1.4991...  0.0758 sec/batch
Epoch: 6/20...  Training Step: 21200...  Training loss: 1.4290...  0.0870 sec/batch
Epoch: 6/20...  Training Step: 21250...  Training loss: 1.6708...  0.0753 sec/batch
Epoch: 6/20...  Training Step: 21300...  Training loss: 1.5693...  0.0833 sec/batch
Epoch: 6/20...  Training Step: 21350...  Training loss: 1.6513...  0.0905 sec/batch
Epoch: 6/20...  Training Step: 21400...  Training loss: 1.4620...  0.0778 sec/batch
Epoch: 6/20...  Training Step: 21450...  Training loss: 1.5650...  0.1010 sec/batch
Epoch: 6/20...  Training Step: 21500...  Training loss: 1.4437...  0.0744 sec/batch
Epoch: 6/20...  Training Step: 21550...  Training loss: 1.5916...  0.0769 sec/batch
Epoch: 6/20...  Training Step: 21600...  Training loss: 1.5931...  0.0976 sec/batch
Epoch: 6/20...  Training Step: 21650...  Training loss: 1.6279...  0.0895 sec/batch
Epoch: 6/20...  Training Step: 21700...  Training loss: 1.7026...  0.1003 sec/batch
Epoch: 6/20...  Training Step: 21750...  Training loss: 1.4039...  0.0802 sec/batch
Epoch: 6/20...  Training Step: 21800...  Training loss: 1.5167...  0.0953 sec/batch
Epoch: 6/20...  Training Step: 21850...  Training loss: 1.5867...  0.0905 sec/batch
Epoch: 6/20...  Training Step: 21900...  Training loss: 1.7200...  0.0766 sec/batch
Epoch: 6/20...  Training Step: 21950...  Training loss: 1.5563...  0.0938 sec/batch
Epoch: 6/20...  Training Step: 22000...  Training loss: 1.5883...  0.0721 sec/batch
Epoch: 6/20...  Training Step: 22050...  Training loss: 1.5580...  0.0859 sec/batch
Epoch: 6/20...  Training Step: 22100...  Training loss: 1.5928...  0.0902 sec/batch
Epoch: 6/20...  Training Step: 22150...  Training loss: 1.4841...  0.0941 sec/batch
Epoch: 6/20...  Training Step: 22200...  Training loss: 1.6139...  0.0928 sec/batch
Epoch: 6/20...  Training Step: 22250...  Training loss: 1.6808...  0.0938 sec/batch
Epoch: 6/20...  Training Step: 22300...  Training loss: 1.5939...  0.0924 sec/batch
Epoch: 6/20...  Training Step: 22350...  Training loss: 1.5500...  0.0838 sec/batch
Epoch: 6/20...  Training Step: 22400...  Training loss: 1.6089...  0.0833 sec/batch
Epoch: 6/20...  Training Step: 22450...  Training loss: 1.4887...  0.0943 sec/batch
Epoch: 6/20...  Training Step: 22500...  Training loss: 1.6812...  0.0969 sec/batch
Epoch: 6/20...  Training Step: 22550...  Training loss: 1.6707...  0.0804 sec/batch
Epoch: 6/20...  Training Step: 22600...  Training loss: 1.4987...  0.0727 sec/batch
Epoch: 6/20...  Training Step: 22650...  Training loss: 1.3569...  0.0703 sec/batch
Epoch: 6/20...  Training Step: 22700...  Training loss: 1.6720...  0.0781 sec/batch
Epoch: 6/20...  Training Step: 22750...  Training loss: 1.3890...  0.0863 sec/batch
Epoch: 6/20...  Training Step: 22800...  Training loss: 1.3773...  0.0785 sec/batch
Epoch: 6/20...  Training Step: 22850...  Training loss: 1.5596...  0.0690 sec/batch
Epoch: 6/20...  Training Step: 22900...  Training loss: 1.6622...  0.0803 sec/batch
Epoch: 6/20...  Training Step: 22950...  Training loss: 1.5504...  0.0808 sec/batch
Epoch: 6/20...  Training Step: 23000...  Training loss: 1.4683...  0.0875 sec/batch
Epoch: 6/20...  Training Step: 23050...  Training loss: 1.6922...  0.0885 sec/batch
Epoch: 6/20...  Training Step: 23100...  Training loss: 1.5522...  0.0856 sec/batch
Epoch: 6/20...  Training Step: 23150...  Training loss: 1.5949...  0.1140 sec/batch
Epoch: 6/20...  Training Step: 23200...  Training loss: 1.4228...  0.1363 sec/batch
Epoch: 6/20...  Training Step: 23250...  Training loss: 1.5105...  0.1300 sec/batch
Epoch: 6/20...  Training Step: 23300...  Training loss: 1.4814...  0.1076 sec/batch
Epoch: 6/20...  Training Step: 23350...  Training loss: 1.4932...  0.1259 sec/batch
Epoch: 6/20...  Training Step: 23400...  Training loss: 1.6526...  0.1023 sec/batch
Epoch: 6/20...  Training Step: 23450...  Training loss: 1.5243...  0.1089 sec/batch
Epoch: 6/20...  Training Step: 23500...  Training loss: 1.6965...  0.1344 sec/batch
Epoch: 6/20...  Training Step: 23550...  Training loss: 1.4643...  0.1816 sec/batch
Epoch: 6/20...  Training Step: 23600...  Training loss: 1.6424...  0.1249 sec/batch
Epoch: 6/20...  Training Step: 23650...  Training loss: 1.5081...  0.0958 sec/batch
Epoch: 6/20...  Training Step: 23700...  Training loss: 1.5093...  0.1111 sec/batch
Epoch: 6/20...  Training Step: 23750...  Training loss: 1.7343...  0.1157 sec/batch
Epoch: 6/20...  Training Step: 23800...  Training loss: 1.5117...  0.1031 sec/batch
Epoch: 7/20...  Training Step: 23850...  Training loss: 1.5714...  0.0897 sec/batch
Epoch: 7/20...  Training Step: 23900...  Training loss: 1.5793...  0.0802 sec/batch
Epoch: 7/20...  Training Step: 23950...  Training loss: 1.5602...  0.0723 sec/batch
Epoch: 7/20...  Training Step: 24000...  Training loss: 1.4580...  0.0952 sec/batch
Epoch: 7/20...  Training Step: 24050...  Training loss: 1.4681...  0.1972 sec/batch
Epoch: 7/20...  Training Step: 24100...  Training loss: 1.6130...  0.1086 sec/batch
Epoch: 7/20...  Training Step: 24150...  Training loss: 1.5916...  0.1337 sec/batch
Epoch: 7/20...  Training Step: 24200...  Training loss: 1.5957...  0.1058 sec/batch
Epoch: 7/20...  Training Step: 24250...  Training loss: 1.5940...  0.0806 sec/batch
Epoch: 7/20...  Training Step: 24300...  Training loss: 1.5995...  0.0943 sec/batch
Epoch: 7/20...  Training Step: 24350...  Training loss: 1.5692...  0.0995 sec/batch
Epoch: 7/20...  Training Step: 24400...  Training loss: 1.6597...  0.0836 sec/batch
Epoch: 7/20...  Training Step: 24450...  Training loss: 1.6382...  0.1045 sec/batch
Epoch: 7/20...  Training Step: 24500...  Training loss: 1.7921...  0.1068 sec/batch
Epoch: 7/20...  Training Step: 24550...  Training loss: 1.4429...  0.0798 sec/batch
Epoch: 7/20...  Training Step: 24600...  Training loss: 1.6100...  0.0788 sec/batch
Epoch: 7/20...  Training Step: 24650...  Training loss: 1.4532...  0.0898 sec/batch
Epoch: 7/20...  Training Step: 24700...  Training loss: 1.4517...  0.0837 sec/batch
Epoch: 7/20...  Training Step: 24750...  Training loss: 1.6019...  0.0948 sec/batch
Epoch: 7/20...  Training Step: 24800...  Training loss: 1.4870...  0.0781 sec/batch
Epoch: 7/20...  Training Step: 24850...  Training loss: 1.5144...  0.0847 sec/batch
Epoch: 7/20...  Training Step: 24900...  Training loss: 1.4159...  0.0735 sec/batch
Epoch: 7/20...  Training Step: 24950...  Training loss: 1.4246...  0.0819 sec/batch
Epoch: 7/20...  Training Step: 25000...  Training loss: 1.5854...  0.0856 sec/batch
Epoch: 7/20...  Training Step: 25050...  Training loss: 1.6333...  0.0786 sec/batch
Epoch: 7/20...  Training Step: 25100...  Training loss: 1.3955...  0.1008 sec/batch
Epoch: 7/20...  Training Step: 25150...  Training loss: 1.6451...  0.0759 sec/batch
Epoch: 7/20...  Training Step: 25200...  Training loss: 1.4775...  0.0722 sec/batch
Epoch: 7/20...  Training Step: 25250...  Training loss: 1.6296...  0.0957 sec/batch
Epoch: 7/20...  Training Step: 25300...  Training loss: 1.6099...  0.0748 sec/batch
Epoch: 7/20...  Training Step: 25350...  Training loss: 1.6173...  0.0834 sec/batch
Epoch: 7/20...  Training Step: 25400...  Training loss: 1.4913...  0.1028 sec/batch
Epoch: 7/20...  Training Step: 25450...  Training loss: 1.6490...  0.0818 sec/batch
Epoch: 7/20...  Training Step: 25500...  Training loss: 1.5371...  0.1004 sec/batch
Epoch: 7/20...  Training Step: 25550...  Training loss: 1.4867...  0.0703 sec/batch
Epoch: 7/20...  Training Step: 25600...  Training loss: 1.4974...  0.0813 sec/batch
Epoch: 7/20...  Training Step: 25650...  Training loss: 1.5172...  0.0919 sec/batch
Epoch: 7/20...  Training Step: 25700...  Training loss: 1.6169...  0.1204 sec/batch
Epoch: 7/20...  Training Step: 25750...  Training loss: 1.5938...  0.0863 sec/batch
Epoch: 7/20...  Training Step: 25800...  Training loss: 1.5298...  0.0934 sec/batch
Epoch: 7/20...  Training Step: 25850...  Training loss: 1.4586...  0.0745 sec/batch
Epoch: 7/20...  Training Step: 25900...  Training loss: 1.5328...  0.0805 sec/batch
Epoch: 7/20...  Training Step: 25950...  Training loss: 1.6615...  0.0705 sec/batch
Epoch: 7/20...  Training Step: 26000...  Training loss: 1.5576...  0.0946 sec/batch
Epoch: 7/20...  Training Step: 26050...  Training loss: 1.5807...  0.0770 sec/batch
Epoch: 7/20...  Training Step: 26100...  Training loss: 1.5513...  0.1414 sec/batch
Epoch: 7/20...  Training Step: 26150...  Training loss: 1.4945...  0.1067 sec/batch
Epoch: 7/20...  Training Step: 26200...  Training loss: 1.5630...  0.0915 sec/batch
Epoch: 7/20...  Training Step: 26250...  Training loss: 1.4644...  0.0697 sec/batch
Epoch: 7/20...  Training Step: 26300...  Training loss: 1.5204...  0.0726 sec/batch
Epoch: 7/20...  Training Step: 26350...  Training loss: 1.5223...  0.0835 sec/batch
Epoch: 7/20...  Training Step: 26400...  Training loss: 1.5956...  0.0856 sec/batch
Epoch: 7/20...  Training Step: 26450...  Training loss: 1.7022...  0.0911 sec/batch
Epoch: 7/20...  Training Step: 26500...  Training loss: 1.4290...  0.0760 sec/batch
Epoch: 7/20...  Training Step: 26550...  Training loss: 1.4513...  0.1342 sec/batch
Epoch: 7/20...  Training Step: 26600...  Training loss: 1.4554...  0.0734 sec/batch
Epoch: 7/20...  Training Step: 26650...  Training loss: 1.5777...  0.0854 sec/batch
Epoch: 7/20...  Training Step: 26700...  Training loss: 1.5284...  0.0836 sec/batch
Epoch: 7/20...  Training Step: 26750...  Training loss: 1.5097...  0.0924 sec/batch
Epoch: 7/20...  Training Step: 26800...  Training loss: 1.7696...  0.0865 sec/batch
Epoch: 7/20...  Training Step: 26850...  Training loss: 1.4989...  0.0932 sec/batch
Epoch: 7/20...  Training Step: 26900...  Training loss: 1.5702...  0.0911 sec/batch
Epoch: 7/20...  Training Step: 26950...  Training loss: 1.5220...  0.1050 sec/batch
Epoch: 7/20...  Training Step: 27000...  Training loss: 1.4421...  0.0962 sec/batch
Epoch: 7/20...  Training Step: 27050...  Training loss: 1.5942...  0.0868 sec/batch
Epoch: 7/20...  Training Step: 27100...  Training loss: 1.4590...  0.0923 sec/batch
Epoch: 7/20...  Training Step: 27150...  Training loss: 1.6516...  0.0851 sec/batch
Epoch: 7/20...  Training Step: 27200...  Training loss: 1.4469...  0.1098 sec/batch
Epoch: 7/20...  Training Step: 27250...  Training loss: 1.4332...  0.0860 sec/batch
Epoch: 7/20...  Training Step: 27300...  Training loss: 1.3986...  0.1398 sec/batch
Epoch: 7/20...  Training Step: 27350...  Training loss: 1.4474...  0.0944 sec/batch
Epoch: 7/20...  Training Step: 27400...  Training loss: 1.5890...  0.0995 sec/batch
Epoch: 7/20...  Training Step: 27450...  Training loss: 1.5266...  0.0698 sec/batch
Epoch: 7/20...  Training Step: 27500...  Training loss: 1.6823...  0.0926 sec/batch
Epoch: 7/20...  Training Step: 27550...  Training loss: 1.7047...  0.0935 sec/batch
Epoch: 7/20...  Training Step: 27600...  Training loss: 1.7515...  0.0781 sec/batch
Epoch: 7/20...  Training Step: 27650...  Training loss: 1.5071...  0.1051 sec/batch
Epoch: 7/20...  Training Step: 27700...  Training loss: 1.5362...  0.0712 sec/batch
Epoch: 7/20...  Training Step: 27750...  Training loss: 1.6593...  0.0783 sec/batch
Epoch: 8/20...  Training Step: 27800...  Training loss: 1.6352...  0.0808 sec/batch
Epoch: 8/20...  Training Step: 27850...  Training loss: 1.5255...  0.0872 sec/batch
Epoch: 8/20...  Training Step: 27900...  Training loss: 1.5303...  0.0970 sec/batch
Epoch: 8/20...  Training Step: 27950...  Training loss: 1.7332...  0.0985 sec/batch
Epoch: 8/20...  Training Step: 28000...  Training loss: 1.4969...  0.0809 sec/batch
Epoch: 8/20...  Training Step: 28050...  Training loss: 1.4444...  0.0757 sec/batch
Epoch: 8/20...  Training Step: 28100...  Training loss: 1.6133...  0.0852 sec/batch
Epoch: 8/20...  Training Step: 28150...  Training loss: 1.6485...  0.0738 sec/batch
Epoch: 8/20...  Training Step: 28200...  Training loss: 1.5369...  0.0861 sec/batch
Epoch: 8/20...  Training Step: 28250...  Training loss: 1.6369...  0.0938 sec/batch
Epoch: 8/20...  Training Step: 28300...  Training loss: 1.6165...  0.0871 sec/batch
Epoch: 8/20...  Training Step: 28350...  Training loss: 1.6268...  0.0713 sec/batch
Epoch: 8/20...  Training Step: 28400...  Training loss: 1.5380...  0.0779 sec/batch
Epoch: 8/20...  Training Step: 28450...  Training loss: 1.5421...  0.0903 sec/batch
Epoch: 8/20...  Training Step: 28500...  Training loss: 1.6025...  0.0828 sec/batch
Epoch: 8/20...  Training Step: 28550...  Training loss: 1.5014...  0.0772 sec/batch
Epoch: 8/20...  Training Step: 28600...  Training loss: 1.5154...  0.0734 sec/batch
Epoch: 8/20...  Training Step: 28650...  Training loss: 1.6878...  0.1073 sec/batch
Epoch: 8/20...  Training Step: 28700...  Training loss: 1.5745...  0.1060 sec/batch
Epoch: 8/20...  Training Step: 28750...  Training loss: 1.6038...  0.0816 sec/batch
Epoch: 8/20...  Training Step: 28800...  Training loss: 1.6646...  0.0849 sec/batch
Epoch: 8/20...  Training Step: 28850...  Training loss: 1.4670...  0.1000 sec/batch
Epoch: 8/20...  Training Step: 28900...  Training loss: 1.4842...  0.0933 sec/batch
Epoch: 8/20...  Training Step: 28950...  Training loss: 1.3866...  0.0935 sec/batch
Epoch: 8/20...  Training Step: 29000...  Training loss: 1.5384...  0.1105 sec/batch
Epoch: 8/20...  Training Step: 29050...  Training loss: 1.5539...  0.0866 sec/batch
Epoch: 8/20...  Training Step: 29100...  Training loss: 1.6012...  0.0913 sec/batch
Epoch: 8/20...  Training Step: 29150...  Training loss: 1.4140...  0.1190 sec/batch
Epoch: 8/20...  Training Step: 29200...  Training loss: 1.5114...  0.0965 sec/batch
Epoch: 8/20...  Training Step: 29250...  Training loss: 1.6154...  0.0815 sec/batch
Epoch: 8/20...  Training Step: 29300...  Training loss: 1.4760...  0.0949 sec/batch
Epoch: 8/20...  Training Step: 29350...  Training loss: 1.6390...  0.0843 sec/batch
Epoch: 8/20...  Training Step: 29400...  Training loss: 1.6083...  0.0828 sec/batch
Epoch: 8/20...  Training Step: 29450...  Training loss: 1.4550...  0.0710 sec/batch
Epoch: 8/20...  Training Step: 29500...  Training loss: 1.5143...  0.0940 sec/batch
Epoch: 8/20...  Training Step: 29550...  Training loss: 1.4781...  0.0901 sec/batch
Epoch: 8/20...  Training Step: 29600...  Training loss: 1.3401...  0.0812 sec/batch
Epoch: 8/20...  Training Step: 29650...  Training loss: 1.6036...  0.0848 sec/batch
Epoch: 8/20...  Training Step: 29700...  Training loss: 1.4655...  0.0850 sec/batch
Epoch: 8/20...  Training Step: 29750...  Training loss: 1.5696...  0.0817 sec/batch
Epoch: 8/20...  Training Step: 29800...  Training loss: 1.5765...  0.0941 sec/batch
Epoch: 8/20...  Training Step: 29850...  Training loss: 1.4741...  0.0777 sec/batch
Epoch: 8/20...  Training Step: 29900...  Training loss: 1.5257...  0.0766 sec/batch
Epoch: 8/20...  Training Step: 29950...  Training loss: 1.5795...  0.0928 sec/batch
Epoch: 8/20...  Training Step: 30000...  Training loss: 1.5907...  0.0856 sec/batch
Epoch: 8/20...  Training Step: 30050...  Training loss: 1.7082...  0.0882 sec/batch
Epoch: 8/20...  Training Step: 30100...  Training loss: 1.4809...  0.0886 sec/batch
Epoch: 8/20...  Training Step: 30150...  Training loss: 1.6129...  0.0967 sec/batch
Epoch: 8/20...  Training Step: 30200...  Training loss: 1.4996...  0.0686 sec/batch
Epoch: 8/20...  Training Step: 30250...  Training loss: 1.5898...  0.0819 sec/batch
Epoch: 8/20...  Training Step: 30300...  Training loss: 1.5929...  0.0712 sec/batch
Epoch: 8/20...  Training Step: 30350...  Training loss: 1.3375...  0.1513 sec/batch
Epoch: 8/20...  Training Step: 30400...  Training loss: 1.6520...  0.0894 sec/batch
Epoch: 8/20...  Training Step: 30450...  Training loss: 1.5814...  0.0939 sec/batch
Epoch: 8/20...  Training Step: 30500...  Training loss: 1.4965...  0.0902 sec/batch
Epoch: 8/20...  Training Step: 30550...  Training loss: 1.5769...  0.1011 sec/batch
Epoch: 8/20...  Training Step: 30600...  Training loss: 1.6214...  0.0790 sec/batch
Epoch: 8/20...  Training Step: 30650...  Training loss: 1.4441...  0.1008 sec/batch
Epoch: 8/20...  Training Step: 30700...  Training loss: 1.5240...  0.0762 sec/batch
Epoch: 8/20...  Training Step: 30750...  Training loss: 1.5156...  0.0748 sec/batch
Epoch: 8/20...  Training Step: 30800...  Training loss: 1.6478...  0.0880 sec/batch
Epoch: 8/20...  Training Step: 30850...  Training loss: 1.5427...  0.1082 sec/batch
Epoch: 8/20...  Training Step: 30900...  Training loss: 1.5128...  0.0851 sec/batch
Epoch: 8/20...  Training Step: 30950...  Training loss: 1.4500...  0.0782 sec/batch
Epoch: 8/20...  Training Step: 31000...  Training loss: 1.4080...  0.0759 sec/batch
Epoch: 8/20...  Training Step: 31050...  Training loss: 1.5035...  0.0736 sec/batch
Epoch: 8/20...  Training Step: 31100...  Training loss: 1.5831...  0.0803 sec/batch
Epoch: 8/20...  Training Step: 31150...  Training loss: 1.4926...  0.0897 sec/batch
Epoch: 8/20...  Training Step: 31200...  Training loss: 1.5686...  0.0874 sec/batch
Epoch: 8/20...  Training Step: 31250...  Training loss: 1.5033...  0.0854 sec/batch
Epoch: 8/20...  Training Step: 31300...  Training loss: 1.5191...  0.1872 sec/batch
Epoch: 8/20...  Training Step: 31350...  Training loss: 1.4792...  0.1163 sec/batch
Epoch: 8/20...  Training Step: 31400...  Training loss: 1.6375...  0.0999 sec/batch
Epoch: 8/20...  Training Step: 31450...  Training loss: 1.6586...  0.0948 sec/batch
Epoch: 8/20...  Training Step: 31500...  Training loss: 1.5596...  0.0735 sec/batch
Epoch: 8/20...  Training Step: 31550...  Training loss: 1.4677...  0.0772 sec/batch
Epoch: 8/20...  Training Step: 31600...  Training loss: 1.5989...  0.0897 sec/batch
Epoch: 8/20...  Training Step: 31650...  Training loss: 1.6604...  0.0879 sec/batch
Epoch: 8/20...  Training Step: 31700...  Training loss: 1.8426...  0.0836 sec/batch
Epoch: 8/20...  Training Step: 31750...  Training loss: 1.5978...  0.0793 sec/batch
Epoch: 9/20...  Training Step: 31800...  Training loss: 1.6505...  0.0937 sec/batch
Epoch: 9/20...  Training Step: 31850...  Training loss: 1.5139...  0.0883 sec/batch
Epoch: 9/20...  Training Step: 31900...  Training loss: 1.5011...  0.0798 sec/batch
Epoch: 9/20...  Training Step: 31950...  Training loss: 1.5080...  0.0968 sec/batch
Epoch: 9/20...  Training Step: 32000...  Training loss: 1.5845...  0.0747 sec/batch
Epoch: 9/20...  Training Step: 32050...  Training loss: 1.4283...  0.0839 sec/batch
Epoch: 9/20...  Training Step: 32100...  Training loss: 1.5503...  0.0847 sec/batch
Epoch: 9/20...  Training Step: 32150...  Training loss: 1.4662...  0.0994 sec/batch
Epoch: 9/20...  Training Step: 32200...  Training loss: 1.5613...  0.1264 sec/batch
Epoch: 9/20...  Training Step: 32250...  Training loss: 1.5798...  0.2490 sec/batch
Epoch: 9/20...  Training Step: 32300...  Training loss: 1.4093...  0.0977 sec/batch
Epoch: 9/20...  Training Step: 32350...  Training loss: 1.7183...  0.1043 sec/batch
Epoch: 9/20...  Training Step: 32400...  Training loss: 1.4302...  0.1226 sec/batch
Epoch: 9/20...  Training Step: 32450...  Training loss: 1.4741...  0.1477 sec/batch
Epoch: 9/20...  Training Step: 32500...  Training loss: 1.4654...  0.1234 sec/batch
Epoch: 9/20...  Training Step: 32550...  Training loss: 1.5457...  0.1444 sec/batch
Epoch: 9/20...  Training Step: 32600...  Training loss: 1.4889...  0.1302 sec/batch
Epoch: 9/20...  Training Step: 32650...  Training loss: 1.5838...  0.1060 sec/batch
Epoch: 9/20...  Training Step: 32700...  Training loss: 1.4321...  0.1291 sec/batch
Epoch: 9/20...  Training Step: 32750...  Training loss: 1.4092...  0.1017 sec/batch
Epoch: 9/20...  Training Step: 32800...  Training loss: 1.4629...  0.1267 sec/batch
Epoch: 9/20...  Training Step: 32850...  Training loss: 1.6998...  0.1073 sec/batch
Epoch: 9/20...  Training Step: 32900...  Training loss: 1.6555...  0.1207 sec/batch
Epoch: 9/20...  Training Step: 32950...  Training loss: 1.4882...  0.1001 sec/batch
Epoch: 9/20...  Training Step: 33000...  Training loss: 1.4583...  0.1263 sec/batch
Epoch: 9/20...  Training Step: 33050...  Training loss: 1.6878...  0.0887 sec/batch
Epoch: 9/20...  Training Step: 33100...  Training loss: 1.4862...  0.1105 sec/batch
Epoch: 9/20...  Training Step: 33150...  Training loss: 1.5107...  0.1163 sec/batch
Epoch: 9/20...  Training Step: 33200...  Training loss: 1.4180...  0.1511 sec/batch
Epoch: 9/20...  Training Step: 33250...  Training loss: 1.6071...  0.1179 sec/batch
Epoch: 9/20...  Training Step: 33300...  Training loss: 1.5656...  0.1112 sec/batch
Epoch: 9/20...  Training Step: 33350...  Training loss: 1.5588...  0.0875 sec/batch
Epoch: 9/20...  Training Step: 33400...  Training loss: 1.5403...  0.0920 sec/batch
Epoch: 9/20...  Training Step: 33450...  Training loss: 1.4595...  0.1160 sec/batch
Epoch: 9/20...  Training Step: 33500...  Training loss: 1.5300...  0.1021 sec/batch
Epoch: 9/20...  Training Step: 33550...  Training loss: 1.4775...  0.0947 sec/batch
Epoch: 9/20...  Training Step: 33600...  Training loss: 1.5494...  0.0867 sec/batch
Epoch: 9/20...  Training Step: 33650...  Training loss: 1.5598...  0.1195 sec/batch
Epoch: 9/20...  Training Step: 33700...  Training loss: 1.8023...  0.0868 sec/batch
Epoch: 9/20...  Training Step: 33750...  Training loss: 1.5721...  0.1199 sec/batch
Epoch: 9/20...  Training Step: 33800...  Training loss: 1.5719...  0.0887 sec/batch
Epoch: 9/20...  Training Step: 33850...  Training loss: 1.5533...  0.1138 sec/batch
Epoch: 9/20...  Training Step: 33900...  Training loss: 1.5563...  0.0978 sec/batch
Epoch: 9/20...  Training Step: 33950...  Training loss: 1.5298...  0.0902 sec/batch
Epoch: 9/20...  Training Step: 34000...  Training loss: 1.7402...  0.0972 sec/batch
Epoch: 9/20...  Training Step: 34050...  Training loss: 1.5150...  0.1191 sec/batch
Epoch: 9/20...  Training Step: 34100...  Training loss: 1.6885...  0.1041 sec/batch
Epoch: 9/20...  Training Step: 34150...  Training loss: 1.5987...  0.1040 sec/batch
Epoch: 9/20...  Training Step: 34200...  Training loss: 1.5448...  0.0934 sec/batch
Epoch: 9/20...  Training Step: 34250...  Training loss: 1.5413...  0.0862 sec/batch
Epoch: 9/20...  Training Step: 34300...  Training loss: 1.6279...  0.1121 sec/batch
Epoch: 9/20...  Training Step: 34350...  Training loss: 1.5562...  0.0918 sec/batch
Epoch: 9/20...  Training Step: 34400...  Training loss: 1.4945...  0.0987 sec/batch
Epoch: 9/20...  Training Step: 34450...  Training loss: 1.6702...  0.0836 sec/batch
Epoch: 9/20...  Training Step: 34500...  Training loss: 1.4869...  0.0955 sec/batch
Epoch: 9/20...  Training Step: 34550...  Training loss: 1.4502...  0.0922 sec/batch
Epoch: 9/20...  Training Step: 34600...  Training loss: 1.5448...  0.0818 sec/batch
Epoch: 9/20...  Training Step: 34650...  Training loss: 1.4264...  0.1077 sec/batch
Epoch: 9/20...  Training Step: 34700...  Training loss: 1.5787...  0.0963 sec/batch
Epoch: 9/20...  Training Step: 34750...  Training loss: 1.5391...  0.1007 sec/batch
Epoch: 9/20...  Training Step: 34800...  Training loss: 1.6039...  0.0969 sec/batch
Epoch: 9/20...  Training Step: 34850...  Training loss: 1.5310...  0.1019 sec/batch
Epoch: 9/20...  Training Step: 34900...  Training loss: 1.6843...  0.1049 sec/batch
Epoch: 9/20...  Training Step: 34950...  Training loss: 1.4762...  0.0827 sec/batch
Epoch: 9/20...  Training Step: 35000...  Training loss: 1.5284...  0.0757 sec/batch
Epoch: 9/20...  Training Step: 35050...  Training loss: 1.6547...  0.0991 sec/batch
Epoch: 9/20...  Training Step: 35100...  Training loss: 1.5576...  0.0971 sec/batch
Epoch: 9/20...  Training Step: 35150...  Training loss: 1.5303...  0.0879 sec/batch
Epoch: 9/20...  Training Step: 35200...  Training loss: 1.5823...  0.0770 sec/batch
Epoch: 9/20...  Training Step: 35250...  Training loss: 1.7048...  0.0968 sec/batch
Epoch: 9/20...  Training Step: 35300...  Training loss: 1.4505...  0.1014 sec/batch
Epoch: 9/20...  Training Step: 35350...  Training loss: 1.4371...  0.1128 sec/batch
Epoch: 9/20...  Training Step: 35400...  Training loss: 1.4641...  0.0884 sec/batch
Epoch: 9/20...  Training Step: 35450...  Training loss: 1.5469...  0.1336 sec/batch
Epoch: 9/20...  Training Step: 35500...  Training loss: 1.5406...  0.1130 sec/batch
Epoch: 9/20...  Training Step: 35550...  Training loss: 1.4615...  0.0940 sec/batch
Epoch: 9/20...  Training Step: 35600...  Training loss: 1.6419...  0.0992 sec/batch
Epoch: 9/20...  Training Step: 35650...  Training loss: 1.6683...  0.0881 sec/batch
Epoch: 9/20...  Training Step: 35700...  Training loss: 1.5895...  0.1247 sec/batch
Epoch: 10/20...  Training Step: 35750...  Training loss: 1.6045...  0.1137 sec/batch
Epoch: 10/20...  Training Step: 35800...  Training loss: 1.5145...  0.1105 sec/batch
Epoch: 10/20...  Training Step: 35850...  Training loss: 1.4561...  0.0990 sec/batch
Epoch: 10/20...  Training Step: 35900...  Training loss: 1.5789...  0.1175 sec/batch
Epoch: 10/20...  Training Step: 35950...  Training loss: 1.5646...  0.1089 sec/batch
Epoch: 10/20...  Training Step: 36000...  Training loss: 1.6307...  0.1058 sec/batch
Epoch: 10/20...  Training Step: 36050...  Training loss: 1.5576...  0.1324 sec/batch
Epoch: 10/20...  Training Step: 36100...  Training loss: 1.5936...  0.0986 sec/batch
Epoch: 10/20...  Training Step: 36150...  Training loss: 1.5268...  0.0826 sec/batch
Epoch: 10/20...  Training Step: 36200...  Training loss: 1.5198...  0.1118 sec/batch
Epoch: 10/20...  Training Step: 36250...  Training loss: 1.4699...  0.1334 sec/batch
Epoch: 10/20...  Training Step: 36300...  Training loss: 1.5474...  0.1127 sec/batch
Epoch: 10/20...  Training Step: 36350...  Training loss: 1.4032...  0.1193 sec/batch
Epoch: 10/20...  Training Step: 36400...  Training loss: 1.5784...  0.0987 sec/batch
Epoch: 10/20...  Training Step: 36450...  Training loss: 1.5738...  0.0800 sec/batch
Epoch: 10/20...  Training Step: 36500...  Training loss: 1.5855...  0.1270 sec/batch
Epoch: 10/20...  Training Step: 36550...  Training loss: 1.5652...  0.1124 sec/batch
Epoch: 10/20...  Training Step: 36600...  Training loss: 1.5781...  0.1156 sec/batch
Epoch: 10/20...  Training Step: 36650...  Training loss: 1.4310...  0.1182 sec/batch
Epoch: 10/20...  Training Step: 36700...  Training loss: 1.4645...  0.1036 sec/batch
Epoch: 10/20...  Training Step: 36750...  Training loss: 1.3673...  0.1570 sec/batch
Epoch: 10/20...  Training Step: 36800...  Training loss: 1.4106...  0.1020 sec/batch
Epoch: 10/20...  Training Step: 36850...  Training loss: 1.3520...  0.1035 sec/batch
Epoch: 10/20...  Training Step: 36900...  Training loss: 1.4730...  0.1208 sec/batch
Epoch: 10/20...  Training Step: 36950...  Training loss: 1.3966...  0.1083 sec/batch
Epoch: 10/20...  Training Step: 37000...  Training loss: 1.5614...  0.1118 sec/batch
Epoch: 10/20...  Training Step: 37050...  Training loss: 1.5708...  0.1131 sec/batch
Epoch: 10/20...  Training Step: 37100...  Training loss: 1.5344...  0.1077 sec/batch
Epoch: 10/20...  Training Step: 37150...  Training loss: 1.5662...  0.1392 sec/batch
Epoch: 10/20...  Training Step: 37200...  Training loss: 1.5251...  0.1147 sec/batch
Epoch: 10/20...  Training Step: 37250...  Training loss: 1.5335...  0.1009 sec/batch
Epoch: 10/20...  Training Step: 37300...  Training loss: 1.5690...  0.1177 sec/batch
Epoch: 10/20...  Training Step: 37350...  Training loss: 1.6238...  0.1028 sec/batch
Epoch: 10/20...  Training Step: 37400...  Training loss: 1.6433...  0.0935 sec/batch
Epoch: 10/20...  Training Step: 37450...  Training loss: 1.5129...  0.1014 sec/batch
Epoch: 10/20...  Training Step: 37500...  Training loss: 1.5597...  0.1173 sec/batch
Epoch: 10/20...  Training Step: 37550...  Training loss: 1.5914...  0.1199 sec/batch
Epoch: 10/20...  Training Step: 37600...  Training loss: 1.3705...  0.0971 sec/batch
Epoch: 10/20...  Training Step: 37650...  Training loss: 1.5492...  0.1452 sec/batch
Epoch: 10/20...  Training Step: 37700...  Training loss: 1.5379...  0.1121 sec/batch
Epoch: 10/20...  Training Step: 37750...  Training loss: 1.4505...  0.1031 sec/batch
Epoch: 10/20...  Training Step: 37800...  Training loss: 1.4315...  0.0949 sec/batch
Epoch: 10/20...  Training Step: 37850...  Training loss: 1.2869...  0.1012 sec/batch
Epoch: 10/20...  Training Step: 37900...  Training loss: 1.4861...  0.0858 sec/batch
Epoch: 10/20...  Training Step: 37950...  Training loss: 1.5488...  0.1531 sec/batch
Epoch: 10/20...  Training Step: 38000...  Training loss: 1.4188...  0.0939 sec/batch
Epoch: 10/20...  Training Step: 38050...  Training loss: 1.4012...  0.1095 sec/batch
Epoch: 10/20...  Training Step: 38100...  Training loss: 1.4482...  0.0833 sec/batch
Epoch: 10/20...  Training Step: 38150...  Training loss: 1.6795...  0.1118 sec/batch
Epoch: 10/20...  Training Step: 38200...  Training loss: 1.5246...  0.1257 sec/batch
Epoch: 10/20...  Training Step: 38250...  Training loss: 1.6288...  0.1214 sec/batch
Epoch: 10/20...  Training Step: 38300...  Training loss: 1.3775...  0.0905 sec/batch
Epoch: 10/20...  Training Step: 38350...  Training loss: 1.3173...  0.1036 sec/batch
Epoch: 10/20...  Training Step: 38400...  Training loss: 1.5289...  0.0851 sec/batch
Epoch: 10/20...  Training Step: 38450...  Training loss: 1.3847...  0.1115 sec/batch
Epoch: 10/20...  Training Step: 38500...  Training loss: 1.5947...  0.1087 sec/batch
Epoch: 10/20...  Training Step: 38550...  Training loss: 1.6464...  0.0933 sec/batch
Epoch: 10/20...  Training Step: 38600...  Training loss: 1.4619...  0.1092 sec/batch
Epoch: 10/20...  Training Step: 38650...  Training loss: 1.5815...  0.0993 sec/batch
Epoch: 10/20...  Training Step: 38700...  Training loss: 1.4955...  0.1124 sec/batch
Epoch: 10/20...  Training Step: 38750...  Training loss: 1.6756...  0.0933 sec/batch
Epoch: 10/20...  Training Step: 38800...  Training loss: 1.4884...  0.0993 sec/batch
Epoch: 10/20...  Training Step: 38850...  Training loss: 1.3976...  0.0904 sec/batch
Epoch: 10/20...  Training Step: 38900...  Training loss: 1.5297...  0.1384 sec/batch
Epoch: 10/20...  Training Step: 38950...  Training loss: 1.5909...  0.1213 sec/batch
Epoch: 10/20...  Training Step: 39000...  Training loss: 1.5794...  0.0803 sec/batch
Epoch: 10/20...  Training Step: 39050...  Training loss: 1.4657...  0.0894 sec/batch
Epoch: 10/20...  Training Step: 39100...  Training loss: 1.4466...  0.0757 sec/batch
Epoch: 10/20...  Training Step: 39150...  Training loss: 1.6531...  0.0933 sec/batch
Epoch: 10/20...  Training Step: 39200...  Training loss: 1.4804...  0.0907 sec/batch
Epoch: 10/20...  Training Step: 39250...  Training loss: 1.5297...  0.0989 sec/batch
Epoch: 10/20...  Training Step: 39300...  Training loss: 1.2403...  0.0838 sec/batch
Epoch: 10/20...  Training Step: 39350...  Training loss: 1.4695...  0.0918 sec/batch
Epoch: 10/20...  Training Step: 39400...  Training loss: 1.5390...  0.0821 sec/batch
Epoch: 10/20...  Training Step: 39450...  Training loss: 1.5023...  0.0889 sec/batch
Epoch: 10/20...  Training Step: 39500...  Training loss: 1.4960...  0.1013 sec/batch
Epoch: 10/20...  Training Step: 39550...  Training loss: 1.7677...  0.0763 sec/batch
Epoch: 10/20...  Training Step: 39600...  Training loss: 1.5904...  0.0992 sec/batch
Epoch: 10/20...  Training Step: 39650...  Training loss: 1.8496...  0.0873 sec/batch
Epoch: 10/20...  Training Step: 39700...  Training loss: 1.8021...  0.0946 sec/batch
Epoch: 11/20...  Training Step: 39750...  Training loss: 1.6871...  0.0806 sec/batch
Epoch: 11/20...  Training Step: 39800...  Training loss: 1.4921...  0.0925 sec/batch
Epoch: 11/20...  Training Step: 39850...  Training loss: 1.3002...  0.0900 sec/batch
Epoch: 11/20...  Training Step: 39900...  Training loss: 1.5394...  0.0955 sec/batch
Epoch: 11/20...  Training Step: 39950...  Training loss: 1.4988...  0.0832 sec/batch
Epoch: 11/20...  Training Step: 40000...  Training loss: 1.3733...  0.0761 sec/batch
Epoch: 11/20...  Training Step: 40050...  Training loss: 1.5052...  0.0962 sec/batch
Epoch: 11/20...  Training Step: 40100...  Training loss: 1.5359...  0.1273 sec/batch
Epoch: 11/20...  Training Step: 40150...  Training loss: 1.6033...  0.1225 sec/batch
Epoch: 11/20...  Training Step: 40200...  Training loss: 1.6227...  0.1116 sec/batch
Epoch: 11/20...  Training Step: 40250...  Training loss: 1.3638...  0.1084 sec/batch
Epoch: 11/20...  Training Step: 40300...  Training loss: 1.4475...  0.1172 sec/batch
Epoch: 11/20...  Training Step: 40350...  Training loss: 1.3183...  0.1910 sec/batch
Epoch: 11/20...  Training Step: 40400...  Training loss: 1.3927...  0.0971 sec/batch
Epoch: 11/20...  Training Step: 40450...  Training loss: 1.4994...  0.1098 sec/batch
Epoch: 11/20...  Training Step: 40500...  Training loss: 1.5186...  0.1181 sec/batch
Epoch: 11/20...  Training Step: 40550...  Training loss: 1.5926...  0.1373 sec/batch
Epoch: 11/20...  Training Step: 40600...  Training loss: 1.5351...  0.1138 sec/batch
Epoch: 11/20...  Training Step: 40650...  Training loss: 1.5363...  0.1005 sec/batch
Epoch: 11/20...  Training Step: 40700...  Training loss: 1.5176...  0.1095 sec/batch
Epoch: 11/20...  Training Step: 40750...  Training loss: 1.4990...  0.0861 sec/batch
Epoch: 11/20...  Training Step: 40800...  Training loss: 1.4551...  0.0804 sec/batch
Epoch: 11/20...  Training Step: 40850...  Training loss: 1.5403...  0.0963 sec/batch
Epoch: 11/20...  Training Step: 40900...  Training loss: 1.5236...  0.1116 sec/batch
Epoch: 11/20...  Training Step: 40950...  Training loss: 1.3391...  0.1004 sec/batch
Epoch: 11/20...  Training Step: 41000...  Training loss: 1.4759...  0.1520 sec/batch
Epoch: 11/20...  Training Step: 41050...  Training loss: 1.4070...  0.0923 sec/batch
Epoch: 11/20...  Training Step: 41100...  Training loss: 1.6368...  0.1219 sec/batch
Epoch: 11/20...  Training Step: 41150...  Training loss: 1.5737...  0.1043 sec/batch
Epoch: 11/20...  Training Step: 41200...  Training loss: 1.5838...  0.1119 sec/batch
Epoch: 11/20...  Training Step: 41250...  Training loss: 1.4112...  0.1000 sec/batch
Epoch: 11/20...  Training Step: 41300...  Training loss: 1.5363...  0.0952 sec/batch
Epoch: 11/20...  Training Step: 41350...  Training loss: 1.4254...  0.0832 sec/batch
Epoch: 11/20...  Training Step: 41400...  Training loss: 1.5420...  0.1083 sec/batch
Epoch: 11/20...  Training Step: 41450...  Training loss: 1.5238...  0.0899 sec/batch
Epoch: 11/20...  Training Step: 41500...  Training loss: 1.5820...  0.1116 sec/batch
Epoch: 11/20...  Training Step: 41550...  Training loss: 1.6694...  0.1148 sec/batch
Epoch: 11/20...  Training Step: 41600...  Training loss: 1.3238...  0.0979 sec/batch
Epoch: 11/20...  Training Step: 41650...  Training loss: 1.4506...  0.0885 sec/batch
Epoch: 11/20...  Training Step: 41700...  Training loss: 1.4942...  0.1282 sec/batch
Epoch: 11/20...  Training Step: 41750...  Training loss: 1.6276...  0.1138 sec/batch
Epoch: 11/20...  Training Step: 41800...  Training loss: 1.5554...  0.0766 sec/batch
Epoch: 11/20...  Training Step: 41850...  Training loss: 1.5313...  0.0934 sec/batch
Epoch: 11/20...  Training Step: 41900...  Training loss: 1.5104...  0.1056 sec/batch
Epoch: 11/20...  Training Step: 41950...  Training loss: 1.5694...  0.0962 sec/batch
Epoch: 11/20...  Training Step: 42000...  Training loss: 1.4569...  0.1201 sec/batch
Epoch: 11/20...  Training Step: 42050...  Training loss: 1.6166...  0.1555 sec/batch
Epoch: 11/20...  Training Step: 42100...  Training loss: 1.6363...  0.0915 sec/batch
Epoch: 11/20...  Training Step: 42150...  Training loss: 1.6142...  0.1150 sec/batch
Epoch: 11/20...  Training Step: 42200...  Training loss: 1.5021...  0.1015 sec/batch
Epoch: 11/20...  Training Step: 42250...  Training loss: 1.5695...  0.0914 sec/batch
Epoch: 11/20...  Training Step: 42300...  Training loss: 1.4404...  0.1083 sec/batch
Epoch: 11/20...  Training Step: 42350...  Training loss: 1.6436...  0.0878 sec/batch
Epoch: 11/20...  Training Step: 42400...  Training loss: 1.5830...  0.1210 sec/batch
Epoch: 11/20...  Training Step: 42450...  Training loss: 1.4371...  0.1067 sec/batch
Epoch: 11/20...  Training Step: 42500...  Training loss: 1.3730...  0.0953 sec/batch
Epoch: 11/20...  Training Step: 42550...  Training loss: 1.6807...  0.2050 sec/batch
Epoch: 11/20...  Training Step: 42600...  Training loss: 1.3629...  0.1398 sec/batch
Epoch: 11/20...  Training Step: 42650...  Training loss: 1.3435...  0.2418 sec/batch
Epoch: 11/20...  Training Step: 42700...  Training loss: 1.5079...  0.1019 sec/batch
Epoch: 11/20...  Training Step: 42750...  Training loss: 1.6357...  0.1293 sec/batch
Epoch: 11/20...  Training Step: 42800...  Training loss: 1.4937...  0.0884 sec/batch
Epoch: 11/20...  Training Step: 42850...  Training loss: 1.4103...  0.1373 sec/batch
Epoch: 11/20...  Training Step: 42900...  Training loss: 1.5659...  0.0996 sec/batch
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-91-6fbd3ad10191> in <module>()
     31                                                  model.final_state,
     32                                                  model.optimizer], 
---> 33                                                  feed_dict=feed)
     34             if (counter % print_every_n == 0):
     35                 end = time.time()

/anaconda2/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    875     try:
    876       result = self._run(None, fetches, feed_dict, options_ptr,
--> 877                          run_metadata_ptr)
    878       if run_metadata:
    879         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

/anaconda2/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1098     if final_fetches or final_targets or (handle and feed_dict_tensor):
   1099       results = self._do_run(handle, final_targets, final_fetches,
-> 1100                              feed_dict_tensor, options, run_metadata)
   1101     else:
   1102       results = []

/anaconda2/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1270     if handle is None:
   1271       return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1272                            run_metadata)
   1273     else:
   1274       return self._do_call(_prun_fn, handle, feeds, fetches)

/anaconda2/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1276   def _do_call(self, fn, *args):
   1277     try:
-> 1278       return fn(*args)
   1279     except errors.OpError as e:
   1280       message = compat.as_text(e.message)

/anaconda2/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1261       self._extend_graph()
   1262       return self._call_tf_sessionrun(
-> 1263           options, feed_dict, fetch_list, target_list, run_metadata)
   1264 
   1265     def _prun_fn(handle, feed_dict, fetch_list):

/anaconda2/envs/py36/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1348     return tf_session.TF_SessionRun_wrapper(
   1349         self._session, options, feed_dict, fetch_list, target_list,
-> 1350         run_metadata)
   1351 
   1352   def _call_tf_sessionprun(self, handle, feed_dict, fetch_list):

KeyboardInterrupt: 

Saved checkpoints

Read up on saving and loading checkpoints here: https://www.tensorflow.org/programmers_guide/variables

In [92]:
tf.train.get_checkpoint_state('checkpoints')
Out[92]:
model_checkpoint_path: "checkpoints/i42800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i23000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i23200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i23400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i23600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i23800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i24000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i24200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i24400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i24600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i24800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i25000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i25200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i25400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i25600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i25800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i26000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i26200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i26400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i26600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i26800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i27000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i27200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i27400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i27600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i27800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i28000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i28200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i28400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i28600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i28800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i29000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i29200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i29400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i29600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i29800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i30000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i30200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i30400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i30600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i30800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i31000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i31200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i31400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i31600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i31800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i32000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i32200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i32400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i32600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i32800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i33000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i33200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i33400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i33600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i33800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i34000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i34200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i34400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i34600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i34800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i35000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i35200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i35400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i35600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i35800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i36000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i36200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i36400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i36600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i36800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i37000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i37200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i37400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i37600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i37800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i38000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i38200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i38400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i38600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i38800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i39000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i39200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i39400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i39600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i39800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i40000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i40200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i40400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i40600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i40800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i41000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i41200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i41400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i41600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i41800_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i42000_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i42200_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i42400_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i42600_l128.ckpt"
all_model_checkpoint_paths: "checkpoints/i42800_l128.ckpt"

Sampling

Now that the network is trained, we'll can use it to generate new text. The idea is that we pass in a character, then the network will predict the next character. We can use the new one, to predict the next one. And we keep doing this to generate all new text. I also included some functionality to prime the network with some text by passing in a string and building up a state from that.

The network gives us predictions for each character. To reduce noise and make things a little less random, I'm going to only choose a new character from the top N most likely characters.

In [109]:
def pick_top_n(preds, vocab_size, top_n=5):
    p = np.squeeze(preds)
    p[np.argsort(p)[:-top_n]] = 0
    p = p / np.sum(p)
    c = np.random.choice(vocab_size, 1, p=p)[0]
    return c
In [112]:
def sample(checkpoint, n_samples, lstm_size, vocab_size, prime="The "):
    samples = [c for c in prime]
    model = CharRNN(len(vocab), lstm_size=lstm_size, sampling=True)
    saver = tf.train.Saver()
    with tf.Session() as sess:
        saver.restore(sess, checkpoint)
        new_state = sess.run(model.initial_state)
        for c in prime:
            x = np.zeros((1, 1))
            x[0,0] = vocab_to_int[c]
            feed = {model.inputs: x,
                    model.keep_prob: 1.,
                    model.initial_state: new_state}
            preds, new_state = sess.run([model.prediction, model.final_state], 
                                         feed_dict=feed)
            
        c = pick_top_n(preds, len(vocab))
        samples.append(int_to_vocab[c])

        for i in range(n_samples):
            x[0,0] = c
            feed = {model.inputs: x,
                    model.keep_prob: 1.,
                    model.initial_state: new_state}
            preds, new_state = sess.run([model.prediction, model.final_state], 
                                         feed_dict=feed)

            c = pick_top_n(preds, len(vocab))
            samples.append(int_to_vocab[c])
        
    return ''.join(samples)

Here, pass in the path to a checkpoint and sample from the network.

In [107]:
tf.train.latest_checkpoint('checkpoints')
Out[107]:
'checkpoints/i42800_l128.ckpt'
In [98]:
checkpoint = tf.train.latest_checkpoint('checkpoints')
samp = sample(checkpoint, 2000, lstm_size, len(vocab), prime="asdf")
print(samp)
y_one_hot: (1, 1, 83) y_reshaped :  (1, 83)
INFO:tensorflow:Restoring parameters from checkpoints/i42800_l128.ckpt
asdful step, as she forth the freshed
so seemed to this same stives, what how they had strill him what had been confersation them to the porticition, while she was thinking in the
certain. "I certain of his word what in a feeling was it of is still this warting that he came his force are himself and that a countre."

"Take and a canstest it's to me the fool shoulder of something the same,"
she she went on the corritate they had thought, and when he had seen
to her at the mansemen as she should took into the cannot had an answer. And with all the struck which a strost went it to a saking the frand who had nothing and was in the
marriage to
be a set,
with show who should the position would not say what she wished a sent, she had stopping to a packed out, so he would
be a possible, and an heed, had bleaded to
the feer of almost the mans of him, show to be, and she had not had been configes in his son, and had being in steps together was a carriage
as in the prusitions of
the convint of the settes, and hangantly shilled
all anything and haste her were seemed and at the portinuss, which he took a feeling at the strath, what had
heard a far of is that he had a chorged and had stood to the
child him. As he said had a change, which
the stertest, and which had not took a confected his finger of his compassion. "It all their first and this that he had been seaned one have staid..."

"Which husband the people she showed, as he was at, thinks.
I strorging the portrent, she's not in in him of a confesss that
in the something that she with the friend they've too,
and he had been all. He would not be almintled this to see her sighities to a pressally one she came to him of a still houses. And she would be that the consciance that she seem all her so cringing the sounding world had and thinking
in the men there thought what he said the charming.

"The
percemally a prince as all a might be a parters of it?" she thought, they would say, and was
all and her husband had been been a people w
In [113]:
checkpoint = tf.train.latest_checkpoint('checkpoints')
samp = sample(checkpoint, 20, lstm_size, len(vocab), prime="asdf")
print(samp)
y_one_hot: (1, 1, 83) y_reshaped :  (1, 83)
INFO:tensorflow:Restoring parameters from checkpoints/i42800_l128.ckpt
[[4.93068434e-03 7.19889626e-02 8.87481030e-04 1.09846886e-04
  4.13725019e-08 3.90535391e-08 4.34985310e-08 2.31744442e-03
  1.38992289e-06 1.78804476e-05 1.37884257e-07 1.19785387e-02
  2.59142951e-03 3.39863496e-03 2.79544702e-06 8.76472086e-07
  8.48887964e-07 9.02525059e-08 2.53493596e-07 9.46878700e-08
  4.60305557e-07 1.80636846e-07 1.18780946e-07 1.29463103e-07
  1.60225042e-07 7.06035789e-05 7.68990023e-04 1.10393669e-03
  7.68006370e-09 2.13106650e-05 2.25075619e-05 2.07472040e-05
  6.64337631e-06 1.43225679e-05 2.47448188e-05 2.86118939e-05
  4.13513635e-06 3.52757597e-05 1.55972180e-06 1.93695469e-05
  7.48257435e-06 5.15886168e-05 5.38114546e-06 3.87762384e-06
  5.30093494e-05 2.25925717e-07 2.55041174e-04 3.92325928e-05
  8.62514662e-06 1.08131699e-05 1.46034399e-05 6.89222190e-07
  4.09565324e-08 2.54362885e-06 1.42374915e-07 7.20279117e-04
  2.58537316e-08 2.85123382e-03 4.01475057e-02 5.02575301e-02
  6.79782256e-02 7.54569331e-03 1.05846822e-02 3.00601125e-02
  5.26868971e-03 1.85952093e-02 3.62629246e-04 2.63186488e-02
  8.81700069e-02 6.49898499e-02 1.10350154e-01 3.42407473e-03
  1.23644155e-02 7.35056121e-04 1.06461048e-01 8.06177557e-02
  1.21362947e-01 7.82333687e-03 9.32097156e-03 7.09635485e-03
  1.94677443e-03 2.13670656e-02 2.45509017e-03]]
[[1.18772425e-02 1.80988774e-01 3.38681275e-03 1.04281539e-03
  1.43481017e-07 2.89860207e-08 1.05263673e-07 2.29996536e-03
  7.43912387e-05 3.01561638e-04 3.10373309e-07 5.21306172e-02
  5.09587582e-03 2.84378175e-02 1.80262850e-05 9.14303300e-08
  4.07492189e-06 2.62985327e-06 1.05803485e-06 7.49624689e-07
  7.48665173e-07 3.11365881e-07 2.10162554e-07 2.38550319e-06
  2.06827735e-07 5.82459441e-04 2.93418160e-03 4.20114212e-03
  1.19520371e-06 2.48434138e-04 4.30476139e-05 1.46848921e-04
  1.98746362e-04 6.05858113e-05 4.48539249e-05 2.10986545e-04
  2.12612122e-05 4.99025882e-05 1.47474075e-05 3.51619237e-04
  2.29187906e-04 3.20438121e-04 2.88136980e-05 4.70595733e-05
  4.17517556e-04 5.84899134e-08 1.10109700e-04 3.73715011e-04
  6.34234821e-05 1.89681896e-06 4.64271550e-04 6.34195203e-06
  3.92337931e-08 4.13803282e-05 4.15280006e-08 1.38746935e-03
  1.07493676e-07 1.68941468e-02 1.13426019e-02 3.07976902e-02
  7.79665215e-03 6.80607036e-02 8.59725941e-03 4.86423448e-03
  1.32919416e-01 5.85257113e-02 2.63148570e-04 2.15120483e-02
  1.63159408e-02 1.82710867e-02 1.02126161e-02 1.75966900e-02
  1.68413222e-02 1.29019981e-03 9.60971601e-03 8.30402449e-02
  1.33684099e-01 1.07472632e-02 1.24752137e-03 8.43535643e-03
  2.44558960e-05 1.22414026e-02 5.99762367e-04]]
[[1.23913884e-02 1.97064534e-01 4.10867995e-03 4.73166205e-04
  1.15234974e-10 1.89565752e-10 7.01488034e-10 8.65790900e-03
  6.14187593e-05 3.80271696e-04 1.48190447e-08 7.04002529e-02
  1.04940096e-02 3.56668904e-02 1.58330531e-05 1.33565636e-09
  7.84276679e-08 2.79439055e-10 8.83883633e-09 3.29576977e-10
  2.60541966e-09 1.21728183e-10 3.32771255e-10 1.11411969e-09
  4.52448468e-10 7.63006508e-04 2.81437184e-03 4.58048517e-03
  2.77210376e-07 8.86975954e-07 3.59006407e-08 4.22498090e-08
  8.17944567e-07 2.37874332e-07 3.42378819e-08 1.21599510e-06
  1.09645617e-08 6.24265249e-06 3.49674623e-09 8.60491184e-07
  1.20435141e-06 1.17495017e-06 2.87675235e-08 9.17118683e-08
  6.11686914e-07 5.39888446e-11 1.20561268e-07 2.32897446e-06
  1.24864044e-07 2.16920459e-09 3.55723409e-06 3.10477155e-09
  4.44814741e-11 1.41116763e-09 6.70309974e-10 8.51374294e-04
  3.18991250e-10 4.16644067e-02 2.38882814e-04 4.39383002e-04
  6.41988881e-04 2.74824262e-01 7.45893980e-04 4.46835475e-04
  9.15336364e-04 1.36758119e-01 7.51104108e-06 3.78750876e-04
  3.11846584e-02 1.90815050e-03 6.56523230e-03 4.37566191e-02
  6.77998702e-04 9.13355143e-06 7.58954091e-03 4.39433381e-02
  2.58553913e-03 5.92005905e-03 2.63272756e-04 4.77521913e-04
  6.36078948e-06 4.91721593e-02 1.35478753e-04]]
[[4.4359567e-07 5.3095173e-06 3.5057923e-07 2.7407800e-09 8.5025553e-20
  1.2765703e-18 4.1329889e-18 4.2118504e-06 2.6470326e-09 7.2035472e-10
  1.0670591e-16 6.8565723e-06 2.4911562e-06 2.0301418e-06 1.0921278e-13
  5.0907966e-21 1.1610456e-14 3.7460736e-24 4.7483021e-18 1.5812954e-22
  1.0703643e-18 2.8576896e-24 1.4083215e-24 4.6111783e-24 7.0238613e-24
  5.8242073e-09 4.7249994e-08 1.8676636e-07 4.7121237e-18 1.7624933e-13
  3.6293993e-13 1.4357707e-15 6.8497481e-14 5.2455897e-13 2.3859441e-14
  6.2227128e-13 3.9040633e-16 5.0718311e-13 3.8281138e-16 8.1367947e-13
  1.0576655e-12 2.0792593e-11 4.1820369e-13 4.4276950e-14 9.4089916e-13
  7.1949656e-21 3.7663608e-14 6.5265978e-13 3.9725500e-14 9.4248853e-17
  5.8447192e-12 2.6441621e-16 2.6933049e-21 2.1382364e-18 7.6339237e-19
  1.5958756e-07 2.4060709e-21 3.8881596e-02 4.8766797e-08 1.2161333e-06
  1.0163902e-09 3.5689048e-02 6.7612368e-06 3.9881143e-06 1.8486740e-05
  3.6103401e-02 4.3899991e-13 1.4610107e-07 1.3316130e-02 7.3387673e-05
  6.3693100e-05 8.7016836e-02 2.0484404e-08 3.9914527e-11 2.1391017e-02
  1.8810334e-06 1.9644869e-05 7.6554865e-01 7.0405781e-06 2.9526418e-06
  2.9716097e-07 1.8312884e-03 4.0719752e-07]]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.04036545 0.         0.
 0.         0.03705106 0.         0.         0.         0.03748123
 0.         0.         0.         0.         0.         0.09033769
 0.         0.         0.         0.         0.         0.7947645
 0.         0.         0.         0.         0.        ]
[0.         0.00494769 0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.00262749
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.0061306  0.         0.         0.         0.
 0.         0.         0.12144288 0.         0.         0.
 0.         0.         0.86485136 0.         0.         0.
 0.         0.         0.         0.         0.        ]
[0.         0.07300976 0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.12155163 0.         0.
 0.         0.6476917  0.         0.         0.         0.12402006
 0.         0.         0.03372684 0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.10113037 0.         0.
 0.         0.19326621 0.         0.         0.         0.19815321
 0.         0.         0.         0.         0.         0.0914096
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.4160406  0.        ]
[0.05012967 0.67351156 0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.16583385
 0.         0.08892483 0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.02160016 0.         0.
 0.         0.         0.         0.         0.        ]
[3.3499625e-02 8.3114213e-01 0.0000000e+00 1.3449575e-01 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 2.7492884e-04 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 5.8758247e-04 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.38492435 0.11932871 0.
 0.         0.         0.         0.         0.10188542 0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.15123676 0.
 0.         0.24262469 0.         0.         0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.01494066 0.         0.
 0.         0.         0.         0.         0.81491387 0.01352534
 0.         0.         0.         0.         0.         0.14330752
 0.         0.         0.01331268 0.         0.         0.
 0.         0.         0.         0.         0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.25302503 0.         0.
 0.         0.56620085 0.         0.         0.         0.07702509
 0.         0.         0.         0.         0.         0.0914897
 0.         0.         0.01225937 0.         0.         0.
 0.         0.         0.         0.         0.        ]
[0.06639651 0.5818722  0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.04279384 0.
 0.         0.         0.11600863 0.         0.         0.
 0.         0.         0.         0.19292882 0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.22403073
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.16583934 0.         0.
 0.16413067 0.         0.         0.2946472  0.         0.
 0.         0.1513521  0.         0.         0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.21785778 0.         0.
 0.         0.16754037 0.         0.         0.         0.09603794
 0.         0.         0.         0.         0.         0.23718943
 0.         0.         0.2813745  0.         0.         0.
 0.         0.         0.         0.         0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.23218247
 0.         0.         0.         0.         0.         0.05204258
 0.         0.         0.16157016 0.46421376 0.08999106 0.
 0.         0.         0.         0.         0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.00586437 0.         0.9110825  0.
 0.         0.         0.04824646 0.02145264 0.01335403 0.
 0.         0.         0.         0.         0.        ]
[0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 2.1858418e-03
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 6.3365133e-04 0.0000000e+00 0.0000000e+00
 1.8316496e-04 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 7.6718810e-05 9.9692065e-01 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00]
[0.         0.4663828  0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.17041871
 0.         0.09868927 0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.1191925
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.1453167  0.         0.
 0.         0.         0.         0.         0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.21471167 0.         0.
 0.         0.         0.         0.         0.         0.10709867
 0.         0.         0.         0.         0.         0.34644637
 0.         0.         0.         0.         0.17614803 0.
 0.         0.15559521 0.         0.         0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.9549338  0.         0.         0.
 0.         0.         0.         0.         0.02912442 0.
 0.         0.         0.00406741 0.         0.         0.00791451
 0.00395976 0.         0.         0.         0.        ]
[9.2805736e-02 8.9358568e-01 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 4.4043467e-04 0.0000000e+00 4.7917030e-04 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 1.2689032e-02 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00 0.0000000e+00
 0.0000000e+00 0.0000000e+00 0.0000000e+00]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.1792833  0.         0.
 0.         0.         0.         0.         0.24747868 0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.10752676 0.3953712  0.
 0.         0.07034004 0.         0.         0.        ]
[0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.         0.         0.         0.         0.
 0.         0.00358985 0.         0.         0.9846613  0.00379213
 0.         0.         0.         0.         0.         0.00543172
 0.         0.         0.00252499 0.         0.         0.
 0.         0.         0.         0.         0.        ]
asdforly, the
point of th
In [ ]:
checkpoint = 'checkpoints/i600_l512.ckpt'
samp = sample(checkpoint, 1000, lstm_size, len(vocab), prime="Far")
print(samp)
In [ ]:
checkpoint = 'checkpoints/i1200_l512.ckpt'
samp = sample(checkpoint, 1000, lstm_size, len(vocab), prime="Far")
print(samp)