In [1]:
# First check the Python version
import sys
if sys.version_info < (3,4):
    print('You are running an older version of Python!\n\n',
          'You should consider updating to Python 3.4.0 or',
          'higher as the libraries built for this course',
          'have only been tested in Python 3.4 and higher.\n')
    print('Try installing the Python 3.5 version of anaconda'
          'and then restart `jupyter notebook`:\n',
          'https://www.continuum.io/downloads\n\n')

# Now get necessary libraries
try:
    import os
    import numpy as np
    import matplotlib.pyplot as plt
    from skimage.transform import resize
    from skimage import data
    from scipy.misc import imresize
    from scipy.ndimage.filters import gaussian_filter
    import IPython.display as ipyd
    import tensorflow as tf
    from libs import utils, gif, datasets, dataset_utils, nb_utils
except ImportError as e:
    print("Make sure you have started notebook in the same directory",
          "as the provided zip file which includes the 'libs' folder",
          "and the file 'utils.py' inside of it.  You will NOT be able",
          "to complete this assignment unless you restart jupyter",
          "notebook inside the directory created by extracting",
          "the zip file or cloning the github repo.")
    print(e)

# We'll tell matplotlib to inline any drawn figures like so:
%matplotlib inline
plt.style.use('ggplot')

In [2]:
import tensorflow as tf
from libs.datasets import CELEB
files = CELEB()

In [3]:
type(files)


Out[3]:
list

In [4]:
len(files)


Out[4]:
202599

In [5]:
from libs.dataset_utils import create_input_pipeline
batch_size = 100
n_epochs = 10
input_shape = [218, 178, 3]
crop_shape = [64, 64, 3]
crop_factor = 0.8
batch = create_input_pipeline(
    files =files,
    batch_size=batch_size,
    n_epochs=n_epochs,
    crop_shape=crop_shape,
    crop_factor = crop_factor,
    shape=input_shape
    )

In [6]:
sess = tf.Session()
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord= coord)

In [7]:
batch_xs = sess.run(batch)
print(batch_xs.shape)
print(batch_xs.dtype, np.max(batch_xs))
plt.imshow(batch_xs[0]/255.0)


(100, 64, 64, 3)
float32 255.0
Out[7]:
<matplotlib.image.AxesImage at 0x7feb073c89e8>

In [8]:
import tensorflow as tf
import requests
txt = requests.get('https://www.gutenberg.org/cache/epub/11/pg11.txt').text

In [9]:
txt[:100]


Out[9]:
"\ufeffProject Gutenberg's Alice's Adventures in Wonderland, by Lewis Carroll\r\n\r\nThis eBook is for the use"

In [10]:
vocab = list(set(txt))
len(txt), len(vocab)


Out[10]:
(167516, 86)

In [11]:
encoder = dict(zip(vocab, range(len(vocab))))
decoder = dict(zip(range(len(vocab)), vocab))

In [12]:
decoder


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

Create the Model


In [13]:
batch_size = 100
sequence_length = 100
n_cells = 256
n_layers = 2
n_chars = len(vocab)

In [14]:
X = tf.placeholder(tf.int32, [None, sequence_length], name='X')
Y = tf.placeholder(tf.int32, [None, sequence_length], name='Y')

In [15]:
embedding = tf.get_variable("embedding", [n_chars, n_cells])
Xs = tf.nn.embedding_lookup(embedding, X)
print(Xs.get_shape().as_list())


[None, 100, 256]

In [16]:
with tf.name_scope('reslice'):
    Xs = [tf.squeeze(seq, [1])
            for seq in tf.split(Xs, sequence_length, 1)]

In [17]:
if n_layers > 1:
    cells = tf.contrib.rnn.MultiRNNCell(
                [tf.contrib.rnn.BasicLSTMCell(num_units=n_cells, state_is_tuple=True) for _ in range(n_layers)], state_is_tuple=True)
    initial_state = cells.zero_state(tf.shape(X)[0], tf.float32)
else:
    cells = tf.contrib.rnn.BasicLSTMCell(num_units=n_cells, state_is_tuple=True)
    initial_state = cells.zero_state(tf.shape(X)[0], tf.float32)

In [18]:
outputs, state = tf.contrib.rnn.static_rnn(cells, Xs, initial_state = initial_state)
outputs_flat = tf.reshape(tf.concat(outputs,1 ), [-1, n_cells])

In [19]:
with tf.variable_scope('prediction'):
    W = tf.get_variable(
        "W", 
        shape=[n_cells, n_chars],
        initializer=tf.random_normal_initializer(stddev=0.1))
    b = tf.get_variable(
        "b",
        shape=[n_chars],
        initializer=tf.random_normal_initializer(stddev=0.1))
    
    logits = tf.matmul(outputs_flat, W) + b
    probs = tf.nn.softmax(logits)
    Y_pred = tf.argmax(probs, 1)

In [20]:
with tf.variable_scope('loss'):
    Y_true_flat = tf.reshape(tf.concat(Y,1), [-1])
    loss = tf.nn.sparse_softmax_cross_entropy_with_logits(logits= logits, labels=Y_true_flat)
    mean_loss = tf.reduce_mean(loss)

In [21]:
with tf.name_scope('optimizer'):
    optimizer = tf.train.AdamOptimizer(learning_rate=0.001)
    gradients = []
    clip = tf.constant(5.0, name='clip')
    for grad, var in optimizer.compute_gradients(mean_loss):
        gradients.append((tf.clip_by_value(grad, -clip, clip), var))
    updates = optimizer.apply_gradients(gradients)

In [22]:
sess = tf.Session()
init = tf.global_variables_initializer()
sess.run(init)

cursor = 0
it_i = 0
while True:
    Xs, Ys = [], []
    for batch_i in range(batch_size):
        if (cursor + sequence_length) >= len(txt) - sequence_length -1 :
            cursor = 0
        Xs.append([encoder[ch] 
                      for ch in txt[cursor:cursor + sequence_length]])
        Ys.append([encoder[ch]
                      for ch in txt[cursor+1 :cursor+ sequence_length + 1]])
        cursor = (cursor + sequence_length)
    Xs = np.array(Xs).astype(np.int32)
    Ys = np.array(Ys).astype(np.int32)
    
    loss_val, _ = sess.run([mean_loss, updates],
                                feed_dict={X: Xs, Y: Ys})
    
    print(it_i, loss_val)
    
    if it_i % 500 == 0:
        p = sess.run([Y_pred], feed_dict={X: Xs})[0]
        preds = [decoder[p_i] for p_i in p]
        print("".join(preds).split('\n'))
    it_i += 1


0 4.47062
['uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu uuuuuuuuuuuuuuuuuu       uuuuuuuuuuuu             uuuuuuuuuuuuuuuuuuuuuuuuuu                  uuuuuuu               uuu   uuuuuuuuuuuuuuuu            uuuuuuuuuuuuuuuuuuuuuuuuuuu                                   uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu       uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu uuuuuuuuuuuuuuuuuuuuuuuuu       uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyyyyyyyyyyyyyyyyyyyyuuuuuuuuuuuuuuuuuuuuuuuuuAAyyyyyyyyuuuuuuu uuuuuuuuuuuuuuuuAAuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyyyyyyyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu             uuuuuuuuuuuuuuuuu                 uuuuuuuuuuuuuuuuuu                                                uuuuuuuuuuuuuuuuu                uuuuuuuu                                  uuuuuuuuuuuuuuuuuuu      uuuuuuuuuuuuuu                uuu                          uuuuuuuuuuuuuuuuuuuuuuuu          uuuuu  uuuuuuuuuuuuuuuuuuuuuuuuu                          uu                      uuuuuuuuuuuuuuuuuuuuu    uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                              uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                uuuuuuuuuu  uuuuuuuuuuuuuuuuuuuuuuu    uuuu  uuuuuuuuuuuuuuuuuuuuuu                          uuuuuuuuu                                               uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu u  uuuuuuuuuuuuuuu                                 u                 uuuuuuuuuuuuuuuuuuu                                        u    uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                            uuuuuuuuuuuuuuuu                                                          uuuuuuu      uuuuuuuuuuu    uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu  u                                     u                             uuuuuuuuuuuuuuuuuuuuuuuuuuu      uuuuuuuuuuuuuuuu                                    uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu    uuuuuuuuu                            uuuuuuuu           uuuuuuuuuuuuuu       uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu uuuuuuuuu                            uuuu       uuuuuuuuuuuuuuuuuuuuuuuuuuu    uuuuuuuuuuuuuuuuuu                         uuuuuu   uuuuuu   uuuuuuu uuuuuuuuuuuuuuu  uuuuuuuuuuuuuuuuuuu          uuuuuuuuuuuuuuuuuuuuuuu uuuuuu                        uuuuuuuuuuuuuuuu             uuuuu    uuu                                                           uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                          uuuuuuuu uu                 uuuuuuuuuuuu      uuuuuuuuuuuuuuuuuu    uuuuu                                                       uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu            uuuuuuuuu         uuuuuuuuuuuuuuuuuuuuuu uuuuuuuuuuuuuuu                             uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyuuuuuuu    uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                                     uuuuuuuuuuuuuuuuuuuuuuuuuu                                   uuuuuuuuuuu uuuuuuuuuuuuuuuuuuuuuuuuuuuuu    uuuuuuuuuuuuuuuuuuuuuuuuuuuu                     u     uuuuu     uuuuuuuuuu uuu  uuuuuu  uuu     uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu         uuuuuuuuuuuuuuuuuuuuuu                                      uuuuuuuuuuuuuuuuuuuuu           uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu   uuuuuuuuuuuuuuu                  uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu      uuuuu uuuuuu uuuuuuuuuuuuuuuu      uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                             uuuuuuuuuuuuuuuuu        uuuuuuuuuuuu    uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                                            uuuuuuuuuuuuuuuuuu                                           uuuuuu     uuuuuuu                     uuuuuuuuuuuuuuuuu                             uuuuuuuuuuuuuuuuuuuuuuu              uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu       uuuuuuuuuu                    uuuuuu         uuuuuuuuuuuuuuuuuuuuuuuuuu   u                             uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu       uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                uuuuuu   uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu    uuuuuuuuuuuuuuuuu     uuuuuuuuuuuuuuuu             uuuuuuuuuuuuuuuuuuu                uuuu           u       uuuuuuuuuuuuuuuuuuuu                       uuuuuuuuuuuuu      uuuuuuuu  uuu  uuuuuuuuuuuuuuuuuuu          uuuu          uuuuuuuuuuuuuuuuuuuuu  uuuMMMMMuuuuuuuuuu   uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                          uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu    uuuuuuu  uuuu                                      uuuuuuuuuuuuuuuuuuuu                     u  uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                    uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu     uuuu                uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu       u    uuuuuuuuu uuuuuu               uuuuuuuuuuuuuuuuuuuuuuu               uuuuuuuuuuuuuuuuuuuuuuu  u           uuuu                                                           uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                u           uuuuuuuuuuuuu        uuuuuuuuuuuuuuuuuuuuuuuuuuuuu                     uuu                                               uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                            uuuuuuuuuuu           uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                            uuuuuuuuuuuuu      uuu        uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu       uuuuuuuuuuuuuuuuuuu                  uuuuuuuuuuuuuuu     uuuuuuuuuuuuuuuuuuuuuuuuuu     uuuuu uuuuuuu       uuuuuuuuuuuuuuuuuuuuuuuuu  uuuuuuuuuuuuuuuuuuuu  uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu      uuuuuuuuuuuuuuuuuu                                     uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu uuu  uu                          uuuuuuu                      uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                 uuuuuuuuuuuuuuuuu                    uuuuuuuuuuuuuuuuuuuuu           u uuuuuuuuuuuu                                                      uuuuuuuuuuuuuuuuuuuuuuuuu             uuuuuuuuuuuuuu                            uuuuuuuu            uuuuuuuuuuuuuuuuuu                                  uuuuuuuuu                                       uuuuuuuuuuuuuuuuuuuuuuuuuuuuu        uuuuuuuuuuuu                                                   uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                                         u    uuuuuuuuuuuuuuuuuuuuuuuuuuuu   uuuuuuu                          uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu         uuuuuuuuuuuuuuuu                                      uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                                     uuuuuuuuuuuuuuuuuuuuuuuuuuu                                          uuuuuuuuuuuuuu                            uuuuuuuuuuuuuuuuuuuu           uuuuuuuuuuuuuuuuuuuuuuuuuu                                          uuuuuuuuuuuuuuuuuuuuu                           uuuuuuuuu                      uuuuuuuuuuuuuuu       uuuuuuuuuuuuu                            yuuuuuuuuuuuuuuuuu                                         uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu   u                uuu                     uuuuuuuuuuuuuuuu   uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                        uuuuuuuuuu uuuuuuuuuuuuuuuu uuuuuuuuuuuuuu                    uuu          uuuuuuuuuuuuu                                        uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                                uuuu                 uuuuuuuuuuuuuuuuuuuu  uuuuuuuuuu                                                                    uuuuuuuuuuuuu      uuuuuuuuuuuuuu                 uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu uuuu                       u        uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu      uuuuuuuuuuuuuuuuuuuu                           uuuu             uuuuuu                              uuuuuuuuuuu              uuu                                  uu             uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu           uuuu          uuuuuuu              uuuuuuuuuuuuuuuuuuuuu               uuuuuuuuuuuuuuuuuuuuuuuu  uuuuuuuuuuuuuu               uuuuuuuuuuuuuuuuuuuuuuuuuu                  uuuuuuuuuuuuuuuuuuuuuuuuuuuu                   uuuu                    uuuuuuuuuuuu    u             uuuuuuuuuuuuuuuuu                            uuuuuuuuuuuuuuuuuuuu uuuuuuuuu                         uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu    uuuuuuuuu                                 uuuuuuuuuuu     uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu       uuuuuuuuuuuuuuuuuuuuuuuuu           uuuuuuuuuuuuuuuuuuuuuuuuuuuuu u                                                                     uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu              uuuuuuuuuuuuuuuuuuuuuuuu               uuuuuuuuuuuuuuuuuuuuuuuuuuu                            uuu       uuuuuuuu  uuuu            u                uuuuuuuuuuuuuuuuuuuuuuuuuuuuu     uuuuuuuuuuuuuuuuu      uuu                             uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu                                     uuuu      uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu         uuuuuuuuuuuuuuuuu                                                 uuuuuuuuu                                                                                           uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu         uuuuuu  uuuu  uuuuuuuuuuuuuuuuuuuuuuuuuu             uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu              uuuuuuuuuuuuuuu                                        uuuuuuuuuuuuuuuuuuuuuuuuu                                  uuuuuuuuuuuuuuu        uuuuuuuuuu        uuuuuuuuuuuuuuuuuu                                        uuuuuuuuuu             uuuuuuuuu uuuuu    uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu            uuuu                          uuuuuuu uuuuuuu    ']
1 4.41401
2 4.29949
3 3.89138
4 3.96631
5 3.6029
6 3.47647
7 3.5332
8 3.49307
9 3.39476
10 3.38481
11 3.40432
12 3.31593
13 3.31032
14 3.3615
15 3.37748
16 3.52148
17 3.20681
18 3.23117
19 3.22429
20 3.24972
21 3.23326
22 3.19188
23 3.21196
24 3.25031
25 3.24332
26 3.18213
27 3.26299
28 3.28679
29 3.22677
30 3.25152
31 3.33615
32 3.45143
33 3.35915
34 3.16821
35 3.18697
36 3.1849
37 3.2093
38 3.20374
39 3.17349
40 3.18329
41 3.23963
42 3.19235
43 3.1603
44 3.2439
45 3.25107
46 3.17443
47 3.24639
48 3.28016
49 3.45438
50 3.22527
51 3.14934
52 3.14216
53 3.13112
54 3.14108
55 3.16823
56 3.10859
57 3.11428
58 3.15482
59 3.09115
60 3.07477
61 3.14931
62 3.12452
63 3.06101
64 3.09218
65 3.23567
66 3.35468
67 3.05443
68 3.00188
69 3.00352
70 2.99636
71 2.99424
72 2.95589
73 2.90804
74 2.93335
75 2.90171
76 2.84996
77 2.86448
78 2.92311
79 2.88172
80 2.83646
81 2.95345
82 3.15045
83 3.06567
84 2.80795
85 2.78249
86 2.81879
87 2.77716
88 2.75074
89 2.70647
90 2.691
91 2.70167
92 2.67209
93 2.6136
94 2.68383
95 2.68859
96 2.64545
97 2.65814
98 2.81388
99 3.03818
100 2.85224
101 2.64318
102 2.61806
103 2.653
104 2.60945
105 2.63492
106 2.5558
107 2.5607
108 2.57203
109 2.54744
110 2.48601
111 2.57254
112 2.59901
113 2.4775
114 2.56762
115 2.73233
116 2.98676
117 2.62201
118 2.58381
119 2.50681
120 2.56355
121 2.50872
122 2.55096
123 2.47225
124 2.44736
125 2.47837
126 2.45149
127 2.41264
128 2.48881
129 2.5013
130 2.40984
131 2.46891
132 2.77677
133 2.90156
134 2.46532
135 2.49886
136 2.49899
137 2.45008
138 2.4731
139 2.44251
140 2.41219
141 2.40817
142 2.38034
143 2.36451
144 2.37697
145 2.41829
146 2.41364
147 2.35822
148 2.4922
149 2.73756
150 2.6917
151 2.40976
152 2.38881
153 2.43039
154 2.4057
155 2.37349
156 2.34699
157 2.33054
158 2.33525
159 2.323
160 2.28437
161 2.32923
162 2.33484
163 2.32088
164 2.3174
165 2.46505
166 2.69131
167 2.57043
168 2.33385
169 2.33125
170 2.34266
171 2.33132
172 2.32083
173 2.28426
174 2.26994
175 2.27026
176 2.28029
177 2.22389
178 2.27438
179 2.30972
180 2.19872
181 2.26997
182 2.48906
183 2.69698
184 2.36992
185 2.29458
186 2.26706
187 2.27166
188 2.26871
189 2.26089
190 2.22741
191 2.19034
192 2.21901
193 2.20819
194 2.17806
195 2.21993
196 2.24403
197 2.16082
198 2.21752
199 2.52721
200 2.64962
201 2.23062
202 2.23132
203 2.19617
204 2.2459
205 2.22167
206 2.17466
207 2.18522
208 2.14732
209 2.15345
210 2.13736
211 2.13847
212 2.17231
213 2.17671
214 2.12165
215 2.26537
216 2.49233
217 2.48647
218 2.17477
219 2.17839
220 2.15167
221 2.19722
222 2.13915
223 2.12704
224 2.10374
225 2.10509
226 2.10929
227 2.08094
228 2.09536
229 2.11107
230 2.09984
231 2.10874
232 2.25923
233 2.47689
234 2.36681
235 2.12204
236 2.13128
237 2.08364
238 2.14074
239 2.08353
240 2.09495
241 2.05281
242 2.04391
243 2.08265
244 2.02191
245 2.06917
246 2.10407
247 2.00764
248 2.05734
249 2.32318
250 2.48657
251 2.19114
252 2.07658
253 2.08625
254 2.05302
255 2.09791
256 2.03676
257 2.05626
258 1.98358
259 2.02527
260 2.01594
261 1.98055
262 2.03296
263 2.05658
264 1.98175
265 2.05224
266 2.32129
267 2.45911
268 2.05545
269 2.04858
270 2.00587
271 2.09602
272 2.02794
273 1.99895
274 2.00215
275 1.95404
276 1.97947
277 1.95887
278 1.95347
279 1.98636
280 2.00389
281 1.95398
282 2.10519
283 2.32226
284 2.3019
285 2.0038
286 2.02695
287 1.97564
288 2.06008
289 1.95725
290 1.97084
291 1.94342
292 1.92484
293 1.9529
294 1.91866
295 1.93136
296 1.94603
297 1.94105
298 1.95687
299 2.1078
300 2.31586
301 2.18898
302 1.97085
303 1.99085
304 1.93225
305 2.00666
306 1.91431
307 1.954
308 1.88516
309 1.89133
310 1.93757
311 1.86836
312 1.91451
313 1.94569
314 1.86827
315 1.91313
316 2.17415
317 2.33024
318 2.04323
319 1.9291
320 1.9542
321 1.92181
322 1.96256
323 1.8931
324 1.92088
325 1.83675
326 1.88668
327 1.87365
328 1.83391
329 1.89017
330 1.92755
331 1.84341
332 1.93363
333 2.15697
334 2.30405
335 1.92437
336 1.92512
337 1.89567
338 1.97271
339 1.89177
340 1.86674
341 1.87515
342 1.82165
343 1.85466
344 1.83028
345 1.81913
346 1.85069
347 1.87204
348 1.83022
349 1.98889
350 2.16727
351 2.16596
352 1.88005
353 1.91303
354 1.86827
355 1.93889
356 1.83737
357 1.8527
358 1.82622
359 1.79363
360 1.8457
361 1.79341
362 1.80707
363 1.82331
364 1.80872
365 1.84232
366 1.98581
367 2.19848
368 2.03629
369 1.87069
370 1.88916
371 1.82467
372 1.89295
373 1.80893
374 1.8451
375 1.76399
376 1.77798
377 1.82668
378 1.75283
379 1.80466
380 1.82694
381 1.75976
382 1.80723
383 2.03321
384 2.20422
385 1.92333
386 1.83678
387 1.85319
388 1.8369
389 1.84549
390 1.79741
391 1.82053
392 1.72389
393 1.7924
394 1.75572
395 1.73576
396 1.77294
397 1.82027
398 1.73938
399 1.84949
400 2.01103
401 2.16728
402 1.82888
403 1.85023
404 1.80315
405 1.88229
406 1.78318
407 1.77989
408 1.76818
409 1.71853
410 1.76271
411 1.72663
412 1.72152
413 1.74709
414 1.76571
415 1.7339
416 1.88338
417 2.03692
418 2.06478
419 1.78479
420 1.8295
421 1.77712
422 1.83974
423 1.73139
424 1.76595
425 1.73192
426 1.69978
427 1.75773
428 1.69279
429 1.7134
430 1.72962
431 1.69076
432 1.75094
433 1.88876
434 2.08429
435 1.9254
436 1.79151
437 1.8016
438 1.74015
439 1.80105
440 1.71398
441 1.7565
442 1.67234
443 1.68611
444 1.7319
445 1.66186
446 1.71436
447 1.72185
448 1.66863
449 1.71912
450 1.92169
451 2.09868
452 1.8211
453 1.75239
454 1.77339
455 1.75519
456 1.74346
457 1.71569
458 1.72817
459 1.64151
460 1.69421
461 1.66439
462 1.6536
463 1.67674
464 1.71977
465 1.65404
466 1.77465
467 1.90075
468 2.02474
469 1.75244
470 1.76708
471 1.73327
472 1.78165
473 1.68224
474 1.70233
475 1.66638
476 1.63857
477 1.67333
478 1.64676
479 1.64799
480 1.64397
481 1.67227
482 1.6652
483 1.77518
484 1.92778
485 1.96863
486 1.70434
487 1.75238
488 1.69816
489 1.74499
490 1.65034
491 1.68247
492 1.64237
493 1.61073
494 1.68267
495 1.6135
496 1.63665
497 1.65629
498 1.59677
499 1.67133
500 1.78042
['h  and the wh d ter ', 'whmter  an thnl t  the would teaaneergthe   anl the   whoetg dtlier eres ', "tf te eethet tou cade sust oe n tear ng tnout  'nd thin the wad ", 'tondneed  aer whmter tinted ter  and thin  aI  shT t cartnus tooar  ', "tiar  aorminn y  'ut tot testtt th tou  thrr an s tot eng tist \r\rAh ", 'tlite tot tn t d tesgtf   aheng ng thite the wedg an thnl the wanht  ', 'ahit t lauder el tooar tt hed te d \r', '\r', "'et te ewhmter thi tholl tust tn the hiat oer  aiar ng ter haad tf ter ", 'wedd  ahs e ng the wa  eng tocd and theng ng tf tittle tlice w d t l ter ', 'wauder elltlier ere   ahml the wh kte an tooar n  tn er t lort nn  and ', "then tas ter sooate '\r", '\r', "'oset  ahe wooaded tf tittle tlice war elf  and tf e tnain the chmk,", 'tedd  aire toose d tp n ter hioa  and the weonht ovten tvts tire tiokeng ', 'tt tt outer e-ahe wauld terr the cery wh e  tf ter heice  and the thet ', 'wueen tittle th e tf ter haad th te d tetk the wasd d ng tevd thet ', 'whTT  t l l  tot tt o ter hve  -and thell t  the hittlr d  an thete  th ', 'tiktlr  ahe waiue taase tnoutd ter hegene tnlne tath the tooetg dtooatire  ', 'tn ter hiktle thmthr t tooare\r', '\r', "'he Miog toote aest e  tn ter hoet tn the thite wabeit wereend te t'he ", 'woonht d d toute theate d tes tas theeughtthe toathtent ng toor -toe ', 'sould terr the ceseee sf the thrrhr  tn the torch aare wnd tes toondt  ', 'thetk  the r woaer -nd ng toar  and the woeoeeeteice tf the tueen ', 'tf e eng tf  ter hpdoreintti torn   to tlecttion --n e tiue the wrthtete ', 'tas toea eng tf the torhess s teoa  ahite taase  tnd tonted toome d ', 'tnoutd tt -au e tiue the woeoed of the tryphon  ahe waueeting tf the ', 'witere s theie -ertenl and the wooueng tf the torpeeated tornddr-lnet ', 'torl d the wnd  aust  tt tath the todtlnt oomettf the tont elle tock ', '\rhrtle \r', '\r', "'h the wai tn  ahth taame  tve   and tetl te ynder ter elf tt ", 'thrder yrd  aheughtthe wioa the wad tet th tne  the  wlain  and t l ', "thrld thel   th tetl tearlne -'he woote airld te tfey west eng tn the ", 'wate  and the Mrok oentleeg to the teteng tf the team  -ahe weseeeng ', 'thrrhri tirld toatge th thme yng toe r -egy   and the wueen s theenly', "tooedtth the teice of the toe eed  tet -'nd the wooasedtf the tete  ahe ", 'wheeed tf the tryphon  tnd t l the tfher aueen totne   ahrld toenge tthe ', "wioa  th the toueure  tooseut of the cett wor e-ote -'hene the Mionng ", 'tn the toreee wn the todtlnte tarld thre the croce of the tock Turtle s ', "terre th e '", '\r', "'ett e  ahe wattlne  th ter elf tew when thie tittle thmter tf ter e", "warld  an the tnrer -hne  au ter elf tnloown tiret  'nd teu the wauld ", 'tecn  aheeughtt l ter hestnsaomr   ahe wamele tnd tioeng terr  of ter ', "woenl enr  'nd teu the wauld tot er t out ter hfher aittle toasl ed  and ", 'tede thE   Tx   teonht tnd tvten thth tadg tnleoetg dthll  aureans tver ', 'whth the tooateof thrter yrg tf tiog tnan tnd teu the wauld tort thth ', 't l the r thmele thmeiui  and tord tnliiarere tn t l the r thn le tuo   ', 'aeaeneer ng ter hfh toesl -enu  and the wadpe woceen ton   ', '\r', "'              hE TNE ", '\r', '\r', "'", "'", '\r', '\rlo tf troject Gutenterg-t tlice s tlier ere  tt thrcer yrg  au tiaaneaateiul ', 't', "'   TNE TT ThE  trETERE OURE EEN  ANEN  TNENE   AR E   R   A  IORT    NE IN  ", '\r', "\r     THEt aorl theuld te tote  t'.. e tf t....cew     ", '\rhen t d t l t  enhtti  torl  tf teiynns tor eti titl te tornd tn  ', "t       teoee 'gwii  thnterg-\rrg o  ...", '\r', '\r', '\r', '\rT iied tveninn  titl tealiie the wroaenns of  -ahe wfletveninu  ', 'thtl te teaete   ', '\r', "'heat ng the Mark  aoom trrleneoowenn trongioveninn  toar  thet tot", 'tne tf   t lnoner toote  toml,enht on the   wark   ah the wound tion ', "ttnd tou ' 'on'toul tnd todtlinuti tn tt the tngter toote  thth ut ", "teapanteon a d tath ut trr ng toml enht oeu l  nn \r'Iheahnl tesl   ", 'th  tor  itt the trctn r thrma of tnt wartiof then tikk ted an ee th ', 'toml ng tnd tontlinutiog trojecthtrtenterg-tm avectlonin work  ah ', "troment toe craUERE GuRE EE   T  Gauee tiand thete en  \r'Iroject ", "'utenterg-tt a leaantir d thete en   and ted tot te tne  tn tou ", "hoanse tor the tronk   ande t tou teahnne taeetnuneorapantion \r'I  tou ", 'honwot toen e t d heng tor tomltd of then txouk  aomele ng tithethe ', "wesl  on aery wxde \r'Iou can tne then txouk tor tovr y wnd trrplnt ", 'thch t  tooation af toaenei ne sark   aealoei  aereoreante  and ', "teatlree \r'Ihe  wod te teuenund tnd trongid tnd trte  t  i -", 'ou tan tow', "trotk nelyy aliEEE   Iath trrlenewowenn tvouk   'Ieaeneienution tn ", 'thcledt to the thote ele tite ted avtertnt y toueonthnt ', 'temeneiinution \r', '\r', "'", "'", "'   TOER   IEREEIITETT  I   ", '\r', '\rhE ToRTEtrOTERE OURE EEN  AENENT  ', '\rIERT  TENN THE  IOR T  IOU TOREEEREN  TN AN  IHE  IOR  ', '\r', ' h troment the troject Gutenterg-tm auneeon tf tromiuiog toe wooa ', 'tontlinution tf txectioniceoork   au tn ng tf t neeenutiog toen tauk ', "ttn t d wfher tark on enhtti  tt t d tas tith the troose t'roject ", '\rutenterg-   aou mneea th touele tith t l the thrse of the torletroject ', '\rutenterg-tm aitestedtatein ree tath then torl tf tfeyng t  ', 'teoee ygrr rterg-\rrg -ice t d \r', '\r', "'", "'hltlnn t'E  rttnel thrma of tnt wnd tar neeenutiog troject Gutenterg-tm ", 'alectloninework  ', 'a', "'...   e tear ng tf tteng tnd trrtiof then troue t tutenterg-tm ", 'alectloninework  aou mn eneli thet tou cade sead  ander eind  anhea th ', 'tnd t kereeanl the thrme of then tikk tedtnd tt orfedt rn tromid a ', "athete en  nore enht  tnaea ent \r'I  tou tootot t aea th t ot dte t l ", 'the chrse of then t aea ent  aou cast torre tp ng tnd teahneetf tiat eu ', 'tnl toultd of troject Gutenterg-tm arectlonin work  an tou  trot d  nn \r', '\r  tou marn tnloettor tfeeln ng tnloul tf tf t kerteto t lroject ', '\rutenterg-tm avectlonin work ond tou contot t aea th te teutd te the ', 'whree of then t aea ent  aou can tneinn t leaurt toom the trrpeotaf ', 'tvoini ah tii etou tain the toettn the tor  itt trreneen  a.E..  ', '\r', "\r....  Iooject Gutenterg--st a leaantir d thete en   '   ten tney we ", 'tne  tf tf t  enhnti  tt t d tas tith t dtxlctioniceoork oe treree tai ', "h eea th te tettd te the chrse of then t aea ent \r'Ihe e wne t loe ", 'theng  thet tou con towtith taue troject trtenterg-tm avectlenin work  ', "aver tith ut tomele ng tith the torl thr e of then t aea ent \r'Ihe ", "tei teet  t.EEHetiw \r'Ihe e wne t liottf theng  tou con towtith troject ", '\rutenterg-tm avectlonin work  tt tou corl w the three of then t aea ent ', 'tnd terl troaedeertooa tor re tnterteto troject Gutente eeth alect enin ', "oork   'Ihe waieteet  t.E.segin \r", '\r', "'....  he Mroject Gutenterg-titerele tlchine s und tion tt he tound tion -", '\rn trrETE  Iu   t louelnelion toml enht tn the touledtinn tf troject ', "\rutenterg-tm avectlenin work   'Iotr y wnl the tn eneneln tark  an the ", "wouledtinn t o tt the trrlenetooenn tt the tndter toote  \r'I  t d", 'tt eneneln tark tn at the trrleneoowenn tt the tndcer toote  tn  tou mne ', 'tiokte  tn the tndter toote   ahntonwot toatnetnleght to troaertetou coou ', 'toue ng  aontlenut og  aereortang  aontleieng tf tooateog toaenedioe ', 'thrk  aett  tf the tark on tiog tn t l teaune te tao troject Gutenterg-', "tne teaaue   'Ih toulse  ahnteue whet tou matl thcpeneiooe wroject ", 'Gute  erg tm auneeon tf tromiuiog tooa tnkerteto tle t enin work  ae ', 'hooa   toelkng troject Gutenterg-theaauk  an tomelent e tath the three of ', 'then t aea ent tor ticn ng the croject Gutenterg-tm aote t    entid thth ', "the wark \r'Iou can'txreny aomele tith the three of then t aea ent te ", 'teen ng toen tau  tn the toie tor enitith tt  t  ere d torl troject ', '\rutenterg-tm aicestedtiin tou caelk tn wath uthtoenke tith tfher  \r', '\r', "'....  he toul enht tise tf the troce oaine wou cne tiokte  tnlentoten e", "thit tou con towtith then tauk \r'Ihne enht tise tt tiue tomldeend tno tt ", "t loueeint ooole tf toenge \r't  tou cne wft  ne the cngcer toote   aoarh ", 'ahe wire of tou  touldee on t  eninn th the chrse of then t aea ent ', 'tegore town ynt ng  aoml ng  aontleyeng  aereortang  aontlenutiog tf ', 'tooatiog toaenedhne sark  aett  tf then tauk tf t d hfher troject ', "\rutenterg-tm airk \r'Ihe Mound tion tide  totteali   t tion  tomee seng ", 'the woul enht oooleletf t d tark on t d tomldee wft  ne the cngcer ', 'toote  \r', 't', "'....  Ndi   tou mede seaeue  tnl teaun dte  th troject Gutenterg- ", '\r', "'...    Ihe Morl w ng toeter e  ahth t kele titge ao  an tfher wt on nnid", 'tnkerteto  ahe torl troject Gutenterg-tm aicestedtist tn err troming t y ', 'whin  er tnd toml tf t lroject Gutenterg-tm airk attd hark of thith the ', "wreise tIroject Gutenterg--sn ear , af tath taith the troose w'roject ", '\rutenterg--tt a  eohoti   tn t kerte   aontleied  aereorean  aeld d  ', 'thuend tf tintlinuti   ', ' ', "'hes txouk tn aor the tse tf t d u  tnd een  tn tottomt ond tath ", "t leut totteatienelnn  tiit  nder \r'Iou can toue an  aone tn t  y tf ", 'teatt  tt wpder the chrme of the troject Gutenterg-tite,tedtn oesed ', 'tith then txouk tf tfeyng t  thih  t n erg-\rrg ', '\r', "'....   I  m dtt eneneln troject Gutenterg-tm arectlonin work on aoaene  ", 'toom the trtlenetowenn tto s tot tomeetnet lot ne tn eneliog toet tt wt ', 'trot d tith tarpanteon af the coul,enhe teuler   ahe wark oon te touend ', 'tnd tontlinuti  th t d u  tt the tndter toote  thth ut trr ng tnd toet ', "tf toanse   'I  tou cne weaeneienutiog tf tromeceng tnherteto t lork ", "thth the troose w'rojechhautenterg--tn euhtti  thth tf t  erreng tf the ", 'wark  aou mast touele tvteer tath the teauete edt  tf trrtteet   t.E.. ', '\rheeughtt.E.. ar tfeeln trapantion aor the cse tf the tark ond the ', 'wroject Gut n erg-tm ahite en  an the tor  itt trreneen   t.E..  r ', 't.E... ', '\r', '\r....   I  m dtt eneneln trojecthtrtenterg-tm avectlonin work on arot d ', 'tith the trrpant on af the coul,enht oewler  aou  wpe t d t neeenution ', 'tost tomele tith teth trreleen   t.E..  heeughtt.E.. and t d t  eninn l ', "thrse on lre  te the touloenht oewler \r'Il  ninn t three oitl te titged ", 'th the troject Gutenterg-tm aicestedtor ttl thrk  aoot d tith the ', 'wrrpanteon af the coul,enht oewler torrd tn the tegangeng tf thes tark \r', '\r', "''...    o tot tndeng of tia nh af temaue the worl troject Gutenterg-tm ", 'aitestedthree ooom then tau   an t d torl  tomeetneng tnlrrgiof then ', 'wark of t d hfher tark on enhtti  thth troject Gutenterg']
501 1.99695
502 1.82483
503 1.70831
504 1.74051
505 1.66457
506 1.7205
507 1.63397
508 1.68055
509 1.58443
510 1.61351
511 1.644
512 1.59557
513 1.62477
514 1.64641
515 1.59425
516 1.64755
517 1.81805
518 2.01652
519 1.71316
520 1.68861
521 1.69476
522 1.69011
523 1.66713
524 1.64175
525 1.65137
526 1.56455
527 1.62009
528 1.59019
529 1.57796
530 1.59908
531 1.63917
532 1.58566
533 1.70718
534 1.80476
535 1.92421
536 1.67777
537 1.69717
538 1.67089
539 1.70997
540 1.60457
541 1.63563
542 1.59659
543 1.564
544 1.60534
545 1.57813
546 1.57226
547 1.5622
548 1.60133
549 1.60552
550 1.70118
551 1.83876
552 1.87553
553 1.63539
554 1.69604
555 1.62729
556 1.68047
557 1.57698
558 1.62406
559 1.57152
560 1.5379
561 1.61653
562 1.54418
563 1.56238
564 1.58831
565 1.52818
566 1.60207
567 1.69991
568 1.92342
569 1.73753
570 1.64385
571 1.68146
572 1.60618
573 1.64851
574 1.56794
575 1.61738
576 1.51691
577 1.55461
578 1.56994
579 1.52593
580 1.55647
581 1.57985
582 1.51965
583 1.59848
584 1.72276
585 1.93239
586 1.64842
587 1.63709
588 1.61836
589 1.63867
590 1.59994
591 1.57527
592 1.57982
593 1.51315
594 1.54749
595 1.52569
596 1.51177
597 1.5289
598 1.57577
599 1.51856
600 1.64231
601 1.72229
602 1.84075
603 1.62396
604 1.63069
605 1.60867
606 1.64676
607 1.53877
608 1.57032
609 1.5266
610 1.5046
611 1.54672
612 1.52366
613 1.5032
614 1.50317
615 1.52772
616 1.54769
617 1.62241
618 1.75662
619 1.79742
620 1.59797
621 1.63101
622 1.57019
623 1.61718
624 1.5087
625 1.55702
626 1.50182
627 1.48155
628 1.55722
629 1.48899
630 1.4913
631 1.53377
632 1.46458
633 1.5353
634 1.63373
635 1.83533
636 1.67083
637 1.58318
638 1.62066
639 1.55364
640 1.58289
641 1.50631
642 1.55634
643 1.44359
644 1.51025
645 1.50632
646 1.46933
647 1.495
648 1.51846
649 1.4579
650 1.55574
651 1.60872
652 1.85455
653 1.59059
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-22-42c28d299a0a> in <module>()
     19 
     20     loss_val, _ = sess.run([mean_loss, updates],
---> 21                                 feed_dict={X: Xs, Y: Ys})
     22 
     23     print(it_i, loss_val)

/home/sungju/projects/sj/CADL/envCADL/lib/python3.5/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    776     try:
    777       result = self._run(None, fetches, feed_dict, options_ptr,
--> 778                          run_metadata_ptr)
    779       if run_metadata:
    780         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

/home/sungju/projects/sj/CADL/envCADL/lib/python3.5/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
    980     if final_fetches or final_targets:
    981       results = self._do_run(handle, final_targets, final_fetches,
--> 982                              feed_dict_string, options, run_metadata)
    983     else:
    984       results = []

/home/sungju/projects/sj/CADL/envCADL/lib/python3.5/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1030     if handle is None:
   1031       return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
-> 1032                            target_list, options, run_metadata)
   1033     else:
   1034       return self._do_call(_prun_fn, self._session, handle, feed_dict,

/home/sungju/projects/sj/CADL/envCADL/lib/python3.5/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1037   def _do_call(self, fn, *args):
   1038     try:
-> 1039       return fn(*args)
   1040     except errors.OpError as e:
   1041       message = compat.as_text(e.message)

/home/sungju/projects/sj/CADL/envCADL/lib/python3.5/site-packages/tensorflow/python/client/session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata)
   1019         return tf_session.TF_Run(session, options,
   1020                                  feed_dict, fetch_list, target_list,
-> 1021                                  status, run_metadata)
   1022 
   1023     def _prun_fn(session, handle, feed_dict, fetch_list):

KeyboardInterrupt: 

In [ ]: