In [25]:
# https://www.tensorflow.org/extend/estimators
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

# tensorflow
import tensorflow as tf
import tensorflow.contrib.rnn as rnn
import tensorflow.contrib.learn as tflearn
import tensorflow.contrib.layers as tflayers

# keras
from tensorflow.contrib.keras.python.keras.layers import Dense, LSTM, GRU, Activation
from tensorflow.contrib.keras.python.keras.utils.data_utils import get_file

# input data
from tensorflow.examples.tutorials.mnist import input_data

# estimators
from tensorflow.contrib import learn

# estimator "builder"
from tensorflow.contrib.learn.python.learn.estimators import model_fn as model_fn_lib

# helpers
import numpy as np
import random
import sys

# enable logs
tf.logging.set_verbosity(tf.logging.INFO)

def sample(preds, temperature=1.0):
    #print(preds)
    return np.argmax(preds)

# THE MODEL
def model_fn(features, targets, mode, params):
    """Model function for Estimator."""
    
    # 1. Configure the model via TensorFlow operations
    # First, build all the model, a good idea is using Keras or tf.layers
    # since these are high-level API's
    #lstm = GRU(128, input_shape=(params["maxlen"], params["vocab_size"]))(features)
    #preds = Dense(params["vocab_size"], activation='sigmoid')(lstm)
    
    # 0. Reformat input shape to become a sequence
    lstm1 = GRU(128, input_shape=(params["maxlen"], params["vocab_size"]),
                return_sequences=True)(features)
    lstm2 = GRU(128)(lstm1)
    preds = Dense(params["vocab_size"])(lstm2)
    preds_softmax = Activation("softmax")(preds)

    # 2. Define the loss function for training/evaluation
    loss = None
    train_op = None
    
    # Calculate Loss (for both TRAIN and EVAL modes)
    if mode != learn.ModeKeys.PREDICT:
        loss = tf.losses.softmax_cross_entropy(
            onehot_labels=targets, logits=preds)

    # 3. Define the training operation/optimizer
    
    # Configure the Training Op (for TRAIN mode)
    if mode == learn.ModeKeys.TRAIN:
        train_op = tf.contrib.layers.optimize_loss(
            loss=loss,
            global_step=tf.contrib.framework.get_global_step(),
            learning_rate=params["learning_rate"],
            optimizer="RMSProp"
        )

    # 4. Generate predictions
    predictions_dict = {
      "preds": preds_softmax
    }
    
    # 5. Define how you want to evaluate the model
    metrics = {
        "accuracy": tf.metrics.accuracy(tf.argmax(input=preds_softmax, axis=1), tf.argmax(input=targets, axis=1))
    }
    
    # 6. Return predictions/loss/train_op/eval_metric_ops in ModelFnOps object
    return model_fn_lib.ModelFnOps(
      mode=mode,
      predictions=predictions_dict,
      loss=loss,
      train_op=train_op,
      eval_metric_ops=metrics)

In [2]:
print('Getting data')

#path = get_file('nietzsche.txt', origin='https://s3.amazonaws.com/text-datasets/nietzsche.txt')
path = 'shakespeare.txt'
text = open(path).read().lower()
print('corpus length:', len(text))

chars = sorted(list(set(text)))
print('total chars:', len(chars))
char_indices = dict((c, i) for i, c in enumerate(chars))
indices_char = dict((i, c) for i, c in enumerate(chars))

# cut the text in semi-redundant sequences of maxlen characters
maxlen = 40
step = 1
sentences = []
next_chars = []
for i in range(0, len(text) - maxlen, step):
    sentences.append(text[i: i + maxlen])
    next_chars.append(text[i + maxlen])
print('nb sequences:', len(sentences))

print('Vectorization...')
X = np.zeros((len(sentences), maxlen, len(chars)), dtype=np.float32)
y = np.zeros((len(sentences), len(chars)), dtype=np.float32)
for i, sentence in enumerate(sentences):
    for t, char in enumerate(sentence):
        X[i, t, char_indices[char]] = 1
    y[i, char_indices[next_chars[i]]] = 1

print(X[0])


Getting data
corpus length: 1115394
total chars: 39
nb sequences: 1115354
Vectorization...
[[ 0.  0.  0. ...,  0.  0.  0.]
 [ 0.  0.  0. ...,  0.  0.  0.]
 [ 0.  0.  0. ...,  0.  0.  0.]
 ..., 
 [ 0.  0.  0. ...,  0.  0.  0.]
 [ 0.  0.  0. ...,  0.  0.  0.]
 [ 0.  0.  0. ...,  0.  0.  0.]]

In [27]:
# PARAMETERS
LEARNING_RATE = 0.01
BATCH_SIZE = 128
STEPS = 10000

NUM_OUTPUTS_PRED = 40

# Set model params
model_params = {"learning_rate": LEARNING_RATE, "vocab_size": len(chars), "maxlen": maxlen}

# Instantiate Estimator
nn = tf.contrib.learn.Estimator(model_fn=model_fn, params=model_params)

# Score accuracy
for iteration in range(1, 600):
    print()
    print('-' * 50)
    print('Iteration', iteration)
  
    # Fit
    print('-' * 40)
    print("Training")
    print('-' * 40)
    nn.fit(x=X, y=y, steps=STEPS, batch_size=BATCH_SIZE)


INFO:tensorflow:Using default config.
INFO:tensorflow:Using config: {'_tf_config': gpu_options {
  per_process_gpu_memory_fraction: 1
}
, '_task_type': None, '_save_checkpoints_steps': None, '_model_dir': None, '_tf_random_seed': None, '_is_chief': True, '_task_id': 0, '_master': '', '_environment': 'local', '_save_checkpoints_secs': 600, '_keep_checkpoint_max': 5, '_num_worker_replicas': 0, '_evaluation_master': '', '_save_summary_steps': 100, '_keep_checkpoint_every_n_hours': 10000, '_num_ps_replicas': 0, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7f63334ee630>}
WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmptus4hnfy

--------------------------------------------------
Iteration 1
----------------------------------------
Training
----------------------------------------
WARNING:tensorflow:From <ipython-input-27-52e4e0701f3c>:24: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with y is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
WARNING:tensorflow:From <ipython-input-27-52e4e0701f3c>:24: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with batch_size is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
WARNING:tensorflow:From <ipython-input-27-52e4e0701f3c>:24: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
/usr/local/lib/python3.4/dist-packages/tensorflow/python/util/deprecation.py:248: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  equality = a == b
INFO:tensorflow:Create CheckpointSaverHook.
INFO:tensorflow:Saving checkpoints for 1 into /tmp/tmptus4hnfy/model.ckpt.
INFO:tensorflow:loss = 3.66388, step = 1
INFO:tensorflow:global_step/sec: 11.4037
INFO:tensorflow:loss = 3.30264, step = 101 (8.770 sec)
INFO:tensorflow:global_step/sec: 11.7097
INFO:tensorflow:loss = 2.64015, step = 201 (8.540 sec)
INFO:tensorflow:global_step/sec: 11.7065
INFO:tensorflow:loss = 2.6065, step = 301 (8.542 sec)
INFO:tensorflow:global_step/sec: 11.6643
INFO:tensorflow:loss = 2.23991, step = 401 (8.573 sec)
INFO:tensorflow:global_step/sec: 11.6397
INFO:tensorflow:loss = 2.29153, step = 501 (8.591 sec)
INFO:tensorflow:global_step/sec: 11.6963
INFO:tensorflow:loss = 2.11677, step = 601 (8.550 sec)
INFO:tensorflow:global_step/sec: 11.682
INFO:tensorflow:loss = 1.82566, step = 701 (8.560 sec)
INFO:tensorflow:global_step/sec: 11.6811
INFO:tensorflow:loss = 2.42411, step = 801 (8.561 sec)
INFO:tensorflow:global_step/sec: 11.6826
INFO:tensorflow:loss = 1.94218, step = 901 (8.560 sec)
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-27-52e4e0701f3c> in <module>()
     22     print("Training")
     23     print('-' * 40)
---> 24     nn.fit(x=X, y=y, steps=STEPS, batch_size=BATCH_SIZE)
     25 
     26 # choose a random sentence

/usr/local/lib/python3.4/dist-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)
    279             _call_location(), decorator_utils.get_qualified_name(func),
    280             func.__module__, arg_name, date, instructions)
--> 281       return func(*args, **kwargs)
    282     new_func.__doc__ = _add_deprecated_arg_notice_to_docstring(
    283         func.__doc__, date, instructions)

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py in fit(self, x, y, input_fn, steps, batch_size, monitors, max_steps)
    412     _verify_input_args(x, y, input_fn, None, batch_size)
    413     if x is not None:
--> 414       SKCompat(self).fit(x, y, batch_size, steps, max_steps, monitors)
    415       return self
    416 

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py in fit(self, x, y, batch_size, steps, max_steps, monitors)
   1315                         steps=steps,
   1316                         max_steps=max_steps,
-> 1317                         monitors=all_monitors)
   1318     return self
   1319 

/usr/local/lib/python3.4/dist-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)
    279             _call_location(), decorator_utils.get_qualified_name(func),
    280             func.__module__, arg_name, date, instructions)
--> 281       return func(*args, **kwargs)
    282     new_func.__doc__ = _add_deprecated_arg_notice_to_docstring(
    283         func.__doc__, date, instructions)

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py in fit(self, x, y, input_fn, steps, batch_size, monitors, max_steps)
    428       hooks.append(basic_session_run_hooks.StopAtStepHook(steps, max_steps))
    429 
--> 430     loss = self._train_model(input_fn=input_fn, hooks=hooks)
    431     logging.info('Loss for final step: %s.', loss)
    432     return self

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py in _train_model(self, input_fn, hooks)
    976         loss = None
    977         while not mon_sess.should_stop():
--> 978           _, loss = mon_sess.run([model_fn_ops.train_op, model_fn_ops.loss])
    979       summary_io.SummaryWriterCache.clear()
    980       return loss

/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py in run(self, fetches, feed_dict, options, run_metadata)
    482                           feed_dict=feed_dict,
    483                           options=options,
--> 484                           run_metadata=run_metadata)
    485 
    486   def should_stop(self):

/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py in run(self, fetches, feed_dict, options, run_metadata)
    818                               feed_dict=feed_dict,
    819                               options=options,
--> 820                               run_metadata=run_metadata)
    821       except _PREEMPTION_ERRORS as e:
    822         logging.info('An error was raised. This may be due to a preemption in '

/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py in run(self, *args, **kwargs)
    774 
    775   def run(self, *args, **kwargs):
--> 776     return self._sess.run(*args, **kwargs)
    777 
    778 

/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py in run(self, fetches, feed_dict, options, run_metadata)
    928                                   feed_dict=feed_dict,
    929                                   options=options,
--> 930                                   run_metadata=run_metadata)
    931 
    932     for hook in self._hooks:

/usr/local/lib/python3.4/dist-packages/tensorflow/python/training/monitored_session.py in run(self, *args, **kwargs)
    774 
    775   def run(self, *args, **kwargs):
--> 776     return self._sess.run(*args, **kwargs)
    777 
    778 

/usr/local/lib/python3.4/dist-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)

/usr/local/lib/python3.4/dist-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 = []

/usr/local/lib/python3.4/dist-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,

/usr/local/lib/python3.4/dist-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)

/usr/local/lib/python3.4/dist-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 [4]:
# choose a random sentence
start_index = random.randint(0, len(text) - maxlen - 1)
sentence = text[start_index: start_index + maxlen]    
    
# generate output using the RNN model
original_sentence = sentence
generated = sentence
for i in range(NUM_OUTPUTS_PRED):
    x = np.zeros((1, maxlen, len(chars)), dtype=np.float32)
    for t, char in enumerate(sentence):
        x[0, t, char_indices[char]] = 1.

    p = None
    for e in nn.predict(x):
        if p is None: p = e["preds"]
    next_index = sample(p)
    next_char = indices_char[next_index]

    generated += next_char
    sentence = sentence[1:] + next_char

print('\n' * 10, '-' * 100)
print('HERE')
print(generated)
print(original_sentence)
print('-' * 100, '\n' * 10)


WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
/usr/local/lib/python3.4/dist-packages/tensorflow/python/util/deprecation.py:248: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  equality = a == b
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
WARNING:tensorflow:From <ipython-input-4-0037bc4a75f1>:15: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101










 ----------------------------------------------------------------------------------------------------
HERE
r wine: 'a health!' quoth he, as if
he he weall our whit hemer, shallll with thi
r wine: 'a health!' quoth he, as if
he h
---------------------------------------------------------------------------------------------------- 











In [10]:
# generate output using the RNN model
original_sentence = "time"
sentence = original_sentence
generated = sentence
for i in range(10):
    x = np.zeros((1, maxlen, len(chars)), dtype=np.float32)
    for t, char in enumerate(sentence):
        x[0, t, char_indices[char]] = 1.

    p = None
    for e in nn.predict(x):
        if p is None: p = e["preds"]
    
    print(p)
    next_index = sample(p)
    next_char = indices_char[next_index]

    generated += next_char
    sentence = sentence[1:] + next_char

print('\n' * 10, '-' * 100)
print('HERE')
print(generated)
print(original_sentence)
print('-' * 100, '\n' * 10)


WARNING:tensorflow:From <ipython-input-10-13d54bdcc739>:11: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
/usr/local/lib/python3.4/dist-packages/tensorflow/python/util/deprecation.py:248: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  equality = a == b
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
[  5.10431186e-04   9.98117208e-01   5.90219262e-11   2.03930277e-08
   2.06349871e-08   2.60475685e-09   2.82078217e-05   3.51113055e-10
   3.47168294e-09   1.67235417e-08   3.75141553e-07   7.82775580e-12
   3.99932887e-09   9.54997086e-06   3.24845595e-09   8.95351988e-08
   7.73334730e-11   5.15784544e-04   1.12831700e-08   2.41030378e-08
   1.61963342e-07   1.10379597e-05   4.23501363e-14   3.85896364e-08
   6.51927166e-07   1.49332386e-08   2.17957226e-08   9.30234746e-05
   3.41106809e-12   5.81926339e-14   6.43336443e-06   1.41718772e-06
   4.23773326e-06   6.97380048e-04   1.07524281e-10   3.80223630e-09
   2.50599356e-16   3.96385121e-06   5.61318136e-13]
WARNING:tensorflow:From <ipython-input-10-13d54bdcc739>:11: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
[  1.88392296e-04   9.96701300e-01   6.89299243e-11   3.92704997e-08
   4.77182098e-08   5.60397133e-08   4.24981044e-05   1.64318018e-10
   1.09672254e-08   3.59650869e-08   1.43609498e-07   2.67432743e-10
   3.16079674e-09   1.19942524e-05   2.33558284e-09   2.75647551e-07
   5.22546877e-08   2.56213383e-03   3.94488708e-08   4.85427254e-09
   2.35454873e-08   2.10934639e-04   4.33996328e-12   1.73394454e-08
   5.62093874e-06   1.34468117e-08   4.37477667e-07   7.28232699e-05
   2.27405629e-11   3.02551635e-15   6.19593993e-05   7.95270182e-07
   3.77228243e-05   8.50870711e-05   1.35057118e-10   9.39591427e-09
   3.50112895e-15   1.75344121e-05   2.22621205e-12]
WARNING:tensorflow:From <ipython-input-10-13d54bdcc739>:11: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
[  2.21534428e-04   9.93981183e-01   6.34928915e-11   7.94155213e-08
   1.02674534e-07   4.81933107e-08   2.57556494e-05   3.74810669e-11
   1.71956902e-08   7.91303520e-08   1.40207007e-07   5.19399579e-10
   4.17961310e-09   3.55434872e-06   1.65757132e-08   8.26823452e-07
   1.42910736e-07   3.92076746e-03   1.12817972e-07   4.10614298e-09
   2.48197640e-08   1.39814988e-03   1.36355163e-11   1.95387866e-08
   9.93353206e-06   9.34284685e-08   5.01213606e-07   1.35778726e-04
   1.06468523e-11   1.60335925e-15   8.48395721e-05   5.26855729e-07
   7.00378150e-05   1.39485695e-04   2.30429412e-10   7.22889339e-08
   1.80896117e-14   6.05607647e-06   1.06008136e-11]
WARNING:tensorflow:From <ipython-input-10-13d54bdcc739>:11: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
[  1.65209058e-04   9.89926696e-01   6.18273141e-11   1.74439037e-07
   2.30940842e-07   9.38005869e-08   3.08850613e-05   5.62107201e-11
   4.53494806e-08   1.72504471e-07   1.14165807e-07   1.51943380e-09
   1.79230639e-08   4.25997041e-06   2.80067649e-08   1.27280111e-06
   1.62253434e-06   5.83881326e-03   2.19799020e-07   2.01575068e-09
   2.57136925e-08   3.34290345e-03   6.28930102e-11   1.89438918e-08
   1.06596972e-05   4.22973642e-07   8.11774441e-07   7.87006720e-05
   2.20400781e-11   9.51636434e-16   3.09886964e-04   9.64305855e-07
   4.87182951e-05   2.32426857e-04   2.98119945e-10   1.03419843e-07
   2.37176967e-14   4.51864707e-06   1.65346070e-11]
WARNING:tensorflow:From <ipython-input-10-13d54bdcc739>:11: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
INFO:tensorflow:Restoring parameters from /tmp/tmpceqk5qg1/model.ckpt-19101
[  1.35492446e-04   9.88932848e-01   7.68679426e-11   2.17841517e-07
   2.85031859e-07   3.32639729e-07   3.20755244e-05   3.45229470e-11
   7.17388815e-08   2.19147609e-07   8.44852224e-08   6.79385925e-09
   1.38642582e-08   2.98846044e-06   2.17521290e-08   1.20390803e-06
   5.98514907e-06   5.55688282e-03   3.79682234e-07   2.08742468e-09
   1.99904431e-08   4.11566952e-03   1.80283843e-10   1.79023711e-08
   1.27436588e-05   6.51291828e-07   7.31034902e-07   9.08361544e-05
   1.09732475e-11   4.26314223e-16   9.04713641e-04   9.94703328e-07
   4.82707001e-05   1.51811502e-04   2.02012337e-10   1.48147834e-07
   1.67475049e-14   4.25541339e-06   4.91029509e-11]
WARNING:tensorflow:From <ipython-input-10-13d54bdcc739>:11: calling BaseEstimator.predict (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
  est = Estimator(...) -> est = SKCompat(Estimator(...))
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-10-13d54bdcc739> in <module>()
      9 
     10     p = None
---> 11     for e in nn.predict(x):
     12         if p is None: p = e["preds"]
     13 

/usr/local/lib/python3.4/dist-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)
    279             _call_location(), decorator_utils.get_qualified_name(func),
    280             func.__module__, arg_name, date, instructions)
--> 281       return func(*args, **kwargs)
    282     new_func.__doc__ = _add_deprecated_arg_notice_to_docstring(
    283         func.__doc__, date, instructions)

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py in predict(self, x, input_fn, batch_size, outputs, as_iterable)
    563         feed_fn=feed_fn,
    564         outputs=outputs,
--> 565         as_iterable=as_iterable)
    566 
    567   def get_variable_value(self, name):

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py in _infer_model(self, input_fn, feed_fn, outputs, as_iterable, iterate_batches)
    855       contrib_framework.create_global_step(g)
    856       features = self._get_features_from_input_fn(input_fn)
--> 857       infer_ops = self._get_predict_ops(features)
    858       predictions = self._filter_predictions(infer_ops.predictions, outputs)
    859       mon_sess = monitored_session.MonitoredSession(

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py in _get_predict_ops(self, features)
   1186     labels = tensor_signature.create_placeholders_from_signatures(
   1187         self._labels_info)
-> 1188     return self._call_model_fn(features, labels, model_fn_lib.ModeKeys.INFER)
   1189 
   1190   def export_savedmodel(

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py in _call_model_fn(self, features, labels, mode)
   1101     if 'model_dir' in model_fn_args:
   1102       kwargs['model_dir'] = self.model_dir
-> 1103     model_fn_results = self._model_fn(features, labels, **kwargs)
   1104 
   1105     if isinstance(model_fn_results, model_fn_lib.ModelFnOps):

<ipython-input-1-576f94d3a7c0> in model_fn(features, targets, mode, params)
     47     # 0. Reformat input shape to become a sequence
     48     lstm1 = GRU(128, input_shape=(params["maxlen"], params["vocab_size"]),
---> 49                 return_sequences=False)(features)
     50     #lstm2 = GRU(128)(lstm1)
     51     preds = Dense(params["vocab_size"])(lstm1)

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/keras/python/keras/layers/recurrent.py in __call__(self, inputs, initial_state, **kwargs)
    277       else:
    278         kwargs['initial_state'] = initial_state
--> 279     return super(Recurrent, self).__call__(inputs, **kwargs)
    280 
    281   def call(self, inputs, mask=None, initial_state=None, training=None):

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/keras/python/keras/engine/topology.py in __call__(self, inputs, **kwargs)
    576 
    577       # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 578       output = self.call(inputs, **kwargs)
    579       output_mask = self.compute_mask(inputs, previous_mask)
    580 

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/keras/python/keras/layers/recurrent.py in call(self, inputs, mask, initial_state, training)
    322         mask=mask,
    323         constants=constants,
--> 324         unroll=self.unroll)
    325     if self.stateful:
    326       updates = []

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/keras/python/keras/backend.py in rnn(step_function, inputs, initial_states, go_backwards, mask, constants, unroll)
   2513         loop_vars=(time, output_ta) + states,
   2514         parallel_iterations=32,
-> 2515         swap_memory=True)
   2516     last_time = final_outputs[0]
   2517     output_ta = final_outputs[1]

/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/control_flow_ops.py in while_loop(cond, body, loop_vars, shape_invariants, parallel_iterations, back_prop, swap_memory, name)
   2621     context = WhileContext(parallel_iterations, back_prop, swap_memory, name)
   2622     ops.add_to_collection(ops.GraphKeys.WHILE_CONTEXT, context)
-> 2623     result = context.BuildLoop(cond, body, loop_vars, shape_invariants)
   2624     return result
   2625 

/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/control_flow_ops.py in BuildLoop(self, pred, body, loop_vars, shape_invariants)
   2454       self.Enter()
   2455       original_body_result, exit_vars = self._BuildLoop(
-> 2456           pred, body, original_loop_vars, loop_vars, shape_invariants)
   2457     finally:
   2458       self.Exit()

/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/control_flow_ops.py in _BuildLoop(self, pred, body, original_loop_vars, loop_vars, shape_invariants)
   2404         structure=original_loop_vars,
   2405         flat_sequence=vars_for_body_with_tensor_arrays)
-> 2406     body_result = body(*packed_vars_for_body)
   2407     if not nest.is_sequence(body_result):
   2408       body_result = [body_result]

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/keras/python/keras/backend.py in _step(time, output_ta_t, *states)
   2502         current_input = input_ta.read(time)
   2503         output, new_states = step_function(current_input,
-> 2504                                            tuple(states) + tuple(constants))
   2505         for state, new_state in zip(states, new_states):
   2506           new_state.set_shape(state.get_shape())

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/keras/python/keras/layers/recurrent.py in step(self, inputs, states)
    868                                                 self.recurrent_kernel_z))
    869       r = self.recurrent_activation(x_r + K.dot(h_tm1 * rec_dp_mask[1],
--> 870                                                 self.recurrent_kernel_r))
    871 
    872       hh = self.activation(x_h + K.dot(r * h_tm1 * rec_dp_mask[2],

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/keras/python/keras/activations.py in hard_sigmoid(x)
     64 
     65 def hard_sigmoid(x):
---> 66   return K.hard_sigmoid(x)
     67 
     68 

/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/keras/python/keras/backend.py in hard_sigmoid(x)
   2817   zero = _to_tensor(0., x.dtype.base_dtype)
   2818   one = _to_tensor(1., x.dtype.base_dtype)
-> 2819   x = clip_ops.clip_by_value(x, zero, one)
   2820   return x
   2821 

/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/clip_ops.py in clip_by_value(t, clip_value_min, clip_value_max, name)
     56 
     57     # Go through list of tensors, for each value in each tensor clip
---> 58     t_min = math_ops.minimum(t, clip_value_max)
     59     t_max = math_ops.maximum(t_min, clip_value_min, name=name)
     60 

/usr/local/lib/python3.4/dist-packages/tensorflow/python/ops/gen_math_ops.py in minimum(x, y, name)
   1390     A `Tensor`. Has the same type as `x`.
   1391   """
-> 1392   result = _op_def_lib.apply_op("Minimum", x=x, y=y, name=name)
   1393   return result
   1394 

/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/op_def_library.py in apply_op(self, op_type_name, name, **keywords)
    766         op = g.create_op(op_type_name, inputs, output_types, name=scope,
    767                          input_types=input_types, attrs=attr_protos,
--> 768                          op_def=op_def)
    769         if output_structure:
    770           outputs = op.outputs

/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py in create_op(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_shapes, compute_device)
   2334     ret = Operation(node_def, self, inputs=inputs, output_types=dtypes,
   2335                     control_inputs=control_inputs, input_types=input_types,
-> 2336                     original_op=self._default_original_op, op_def=op_def)
   2337     if compute_shapes:
   2338       set_shapes_for_outputs(ret)

/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py in __init__(self, node_def, g, inputs, output_types, control_inputs, input_types, original_op, op_def)
   1237     # created.
   1238     self._id_value = self._graph._next_id()  # pylint: disable=protected-access
-> 1239     self._recompute_node_def()
   1240 
   1241   def colocation_groups(self):

/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py in _recompute_node_def(self)
   1400   # Methods below are used when building the NodeDef and Graph proto.
   1401   def _recompute_node_def(self):
-> 1402     del self._node_def.input[:]
   1403     self._node_def.input.extend([t._as_node_def_input() for t in self._inputs])
   1404     if self._control_inputs:

/usr/local/lib/python3.4/dist-packages/google/protobuf/internal/containers.py in __delitem__(self, key)
    318     self._message_listener.Modified()
    319 
--> 320   def __delitem__(self, key):
    321     """Deletes the item at the specified position."""
    322     del self._values[key]

KeyboardInterrupt: 

In [ ]: