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 [28]:
# 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 0x7f6341474588>}
WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpb3eyyydg

--------------------------------------------------
Iteration 1
----------------------------------------
Training
----------------------------------------
WARNING:tensorflow:From <ipython-input-28-c9008343d737>: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-28-c9008343d737>: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-28-c9008343d737>: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/tmpb3eyyydg/model.ckpt.
INFO:tensorflow:loss = 3.66463, step = 1
INFO:tensorflow:global_step/sec: 6.73345
INFO:tensorflow:loss = 3.11169, step = 101 (14.851 sec)
INFO:tensorflow:global_step/sec: 6.73881
INFO:tensorflow:loss = 2.57609, step = 201 (14.839 sec)
INFO:tensorflow:global_step/sec: 6.63066
INFO:tensorflow:loss = 2.2082, step = 301 (15.081 sec)
INFO:tensorflow:global_step/sec: 6.5516
INFO:tensorflow:loss = 2.36044, step = 401 (15.263 sec)
INFO:tensorflow:global_step/sec: 6.67613
INFO:tensorflow:loss = 2.12642, step = 501 (14.979 sec)
INFO:tensorflow:global_step/sec: 6.61581
INFO:tensorflow:loss = 2.0016, step = 601 (15.115 sec)
INFO:tensorflow:global_step/sec: 6.3953
INFO:tensorflow:loss = 1.99158, step = 701 (15.636 sec)
INFO:tensorflow:global_step/sec: 6.60731
INFO:tensorflow:loss = 2.09668, step = 801 (15.135 sec)
INFO:tensorflow:global_step/sec: 6.46653
INFO:tensorflow:loss = 1.94819, step = 901 (15.464 sec)
INFO:tensorflow:global_step/sec: 6.69827
INFO:tensorflow:loss = 1.98563, step = 1001 (14.929 sec)
INFO:tensorflow:global_step/sec: 6.62779
INFO:tensorflow:loss = 2.14272, step = 1101 (15.088 sec)
INFO:tensorflow:global_step/sec: 6.73226
INFO:tensorflow:loss = 1.71009, step = 1201 (14.854 sec)
INFO:tensorflow:global_step/sec: 6.78307
INFO:tensorflow:loss = 1.94125, step = 1301 (14.743 sec)
INFO:tensorflow:global_step/sec: 6.63439
INFO:tensorflow:loss = 1.77978, step = 1401 (15.073 sec)
INFO:tensorflow:global_step/sec: 6.70101
INFO:tensorflow:loss = 1.88542, step = 1501 (14.923 sec)
INFO:tensorflow:global_step/sec: 6.74343
INFO:tensorflow:loss = 1.82332, step = 1601 (14.829 sec)
INFO:tensorflow:global_step/sec: 6.81863
INFO:tensorflow:loss = 2.14602, step = 1701 (14.666 sec)
INFO:tensorflow:global_step/sec: 6.84734
INFO:tensorflow:loss = 1.97756, step = 1801 (14.604 sec)
INFO:tensorflow:global_step/sec: 6.69331
INFO:tensorflow:loss = 1.82729, step = 1901 (14.940 sec)
INFO:tensorflow:global_step/sec: 6.83327
INFO:tensorflow:loss = 1.91847, step = 2001 (14.634 sec)
INFO:tensorflow:global_step/sec: 6.83907
INFO:tensorflow:loss = 1.71896, step = 2101 (14.622 sec)
INFO:tensorflow:global_step/sec: 6.80297
INFO:tensorflow:loss = 1.77582, step = 2201 (14.699 sec)
INFO:tensorflow:global_step/sec: 6.85883
INFO:tensorflow:loss = 2.14473, step = 2301 (14.580 sec)
INFO:tensorflow:global_step/sec: 6.90686
INFO:tensorflow:loss = 2.07307, step = 2401 (14.478 sec)
INFO:tensorflow:global_step/sec: 6.92135
INFO:tensorflow:loss = 1.93684, step = 2501 (14.448 sec)
INFO:tensorflow:global_step/sec: 6.9415
INFO:tensorflow:loss = 2.08349, step = 2601 (14.406 sec)
INFO:tensorflow:global_step/sec: 6.70055
INFO:tensorflow:loss = 1.68604, step = 2701 (14.924 sec)
INFO:tensorflow:global_step/sec: 6.85602
INFO:tensorflow:loss = 1.89287, step = 2801 (14.586 sec)
INFO:tensorflow:global_step/sec: 6.89494
INFO:tensorflow:loss = 1.84995, step = 2901 (14.503 sec)
INFO:tensorflow:global_step/sec: 6.77646
INFO:tensorflow:loss = 1.76912, step = 3001 (14.757 sec)
INFO:tensorflow:global_step/sec: 6.68529
INFO:tensorflow:loss = 1.89526, step = 3101 (14.958 sec)
INFO:tensorflow:global_step/sec: 6.57561
INFO:tensorflow:loss = 1.6698, step = 3201 (15.208 sec)
INFO:tensorflow:global_step/sec: 6.38189
INFO:tensorflow:loss = 1.72777, step = 3301 (15.669 sec)
INFO:tensorflow:global_step/sec: 6.38287
INFO:tensorflow:loss = 1.87946, step = 3401 (15.667 sec)
INFO:tensorflow:global_step/sec: 6.88148
INFO:tensorflow:loss = 1.90305, step = 3501 (14.532 sec)
INFO:tensorflow:global_step/sec: 6.69948
INFO:tensorflow:loss = 1.68267, step = 3601 (14.926 sec)
INFO:tensorflow:global_step/sec: 6.84833
INFO:tensorflow:loss = 2.0533, step = 3701 (14.602 sec)
INFO:tensorflow:global_step/sec: 6.5583
INFO:tensorflow:loss = 1.77252, step = 3801 (15.248 sec)
INFO:tensorflow:global_step/sec: 6.52343
INFO:tensorflow:loss = 1.85812, step = 3901 (15.329 sec)
INFO:tensorflow:global_step/sec: 6.89939
INFO:tensorflow:loss = 1.55516, step = 4001 (14.494 sec)
INFO:tensorflow:Saving checkpoints for 4019 into /tmp/tmpb3eyyydg/model.ckpt.
INFO:tensorflow:global_step/sec: 6.42768
INFO:tensorflow:loss = 1.93629, step = 4101 (15.558 sec)
INFO:tensorflow:global_step/sec: 6.83746
INFO:tensorflow:loss = 1.92823, step = 4201 (14.625 sec)
INFO:tensorflow:global_step/sec: 6.66711
INFO:tensorflow:loss = 1.81239, step = 4301 (14.999 sec)
INFO:tensorflow:global_step/sec: 6.53779
INFO:tensorflow:loss = 1.70003, step = 4401 (15.296 sec)
INFO:tensorflow:global_step/sec: 6.64906
INFO:tensorflow:loss = 1.96269, step = 4501 (15.040 sec)
INFO:tensorflow:global_step/sec: 6.7806
INFO:tensorflow:loss = 1.88445, step = 4601 (14.748 sec)
INFO:tensorflow:global_step/sec: 6.46409
INFO:tensorflow:loss = 1.83989, step = 4701 (15.470 sec)
INFO:tensorflow:global_step/sec: 6.57378
INFO:tensorflow:loss = 2.01499, step = 4801 (15.213 sec)
INFO:tensorflow:global_step/sec: 6.61291
INFO:tensorflow:loss = 1.79146, step = 4901 (15.121 sec)
INFO:tensorflow:global_step/sec: 6.70305
INFO:tensorflow:loss = 1.9002, step = 5001 (14.919 sec)
INFO:tensorflow:global_step/sec: 6.43195
INFO:tensorflow:loss = 1.67045, step = 5101 (15.547 sec)
INFO:tensorflow:global_step/sec: 6.45031
INFO:tensorflow:loss = 1.9173, step = 5201 (15.503 sec)
INFO:tensorflow:global_step/sec: 6.42163
INFO:tensorflow:loss = 1.77776, step = 5301 (15.572 sec)
INFO:tensorflow:global_step/sec: 6.43873
INFO:tensorflow:loss = 1.81222, step = 5401 (15.531 sec)
INFO:tensorflow:global_step/sec: 6.44515
INFO:tensorflow:loss = 2.11882, step = 5501 (15.516 sec)
INFO:tensorflow:global_step/sec: 6.36898
INFO:tensorflow:loss = 1.63466, step = 5601 (15.701 sec)
INFO:tensorflow:global_step/sec: 6.35928
INFO:tensorflow:loss = 1.85063, step = 5701 (15.725 sec)
INFO:tensorflow:global_step/sec: 6.39468
INFO:tensorflow:loss = 1.65461, step = 5801 (15.638 sec)
INFO:tensorflow:global_step/sec: 6.40248
INFO:tensorflow:loss = 1.7843, step = 5901 (15.619 sec)
INFO:tensorflow:global_step/sec: 6.57913
INFO:tensorflow:loss = 1.78454, step = 6001 (15.200 sec)
INFO:tensorflow:global_step/sec: 6.51546
INFO:tensorflow:loss = 1.84334, step = 6101 (15.348 sec)
INFO:tensorflow:global_step/sec: 6.46745
INFO:tensorflow:loss = 1.80359, step = 6201 (15.462 sec)
INFO:tensorflow:global_step/sec: 6.48594
INFO:tensorflow:loss = 1.55682, step = 6301 (15.418 sec)
INFO:tensorflow:global_step/sec: 6.49107
INFO:tensorflow:loss = 2.02087, step = 6401 (15.406 sec)
INFO:tensorflow:global_step/sec: 6.46097
INFO:tensorflow:loss = 1.67637, step = 6501 (15.477 sec)
INFO:tensorflow:global_step/sec: 6.53119
INFO:tensorflow:loss = 1.66554, step = 6601 (15.311 sec)
INFO:tensorflow:global_step/sec: 6.44324
INFO:tensorflow:loss = 1.889, step = 6701 (15.520 sec)
INFO:tensorflow:global_step/sec: 6.49192
INFO:tensorflow:loss = 1.78155, step = 6801 (15.404 sec)
INFO:tensorflow:global_step/sec: 6.52685
INFO:tensorflow:loss = 1.62006, step = 6901 (15.321 sec)
INFO:tensorflow:global_step/sec: 6.37616
INFO:tensorflow:loss = 1.76569, step = 7001 (15.683 sec)
INFO:tensorflow:global_step/sec: 6.59445
INFO:tensorflow:loss = 1.76614, step = 7101 (15.164 sec)
INFO:tensorflow:global_step/sec: 6.58087
INFO:tensorflow:loss = 1.71921, step = 7201 (15.196 sec)
INFO:tensorflow:global_step/sec: 6.59366
INFO:tensorflow:loss = 1.65369, step = 7301 (15.166 sec)
INFO:tensorflow:global_step/sec: 6.59498
INFO:tensorflow:loss = 1.86757, step = 7401 (15.163 sec)
INFO:tensorflow:global_step/sec: 6.70763
INFO:tensorflow:loss = 1.69586, step = 7501 (14.908 sec)
INFO:tensorflow:global_step/sec: 6.67181
INFO:tensorflow:loss = 1.65873, step = 7601 (14.988 sec)
INFO:tensorflow:global_step/sec: 6.55402
INFO:tensorflow:loss = 1.7183, step = 7701 (15.258 sec)
INFO:tensorflow:global_step/sec: 6.6686
INFO:tensorflow:loss = 1.90489, step = 7801 (14.996 sec)
INFO:tensorflow:global_step/sec: 6.67061
INFO:tensorflow:loss = 1.61757, step = 7901 (14.991 sec)
INFO:tensorflow:Saving checkpoints for 7939 into /tmp/tmpb3eyyydg/model.ckpt.
INFO:tensorflow:global_step/sec: 6.09731
INFO:tensorflow:loss = 1.96585, step = 8001 (16.401 sec)
INFO:tensorflow:global_step/sec: 6.68294
INFO:tensorflow:loss = 1.54977, step = 8101 (14.963 sec)
INFO:tensorflow:global_step/sec: 6.60993
INFO:tensorflow:loss = 1.64236, step = 8201 (15.129 sec)
INFO:tensorflow:global_step/sec: 6.61586
INFO:tensorflow:loss = 1.56314, step = 8301 (15.115 sec)
INFO:tensorflow:global_step/sec: 6.67163
INFO:tensorflow:loss = 1.74221, step = 8401 (14.989 sec)
INFO:tensorflow:global_step/sec: 6.78086
INFO:tensorflow:loss = 1.74049, step = 8501 (14.747 sec)
INFO:tensorflow:global_step/sec: 6.71027
INFO:tensorflow:loss = 1.59981, step = 8601 (14.903 sec)
INFO:tensorflow:global_step/sec: 6.68742
INFO:tensorflow:loss = 1.89076, step = 8701 (14.953 sec)
INFO:tensorflow:global_step/sec: 6.73103
INFO:tensorflow:loss = 1.49434, step = 8801 (14.857 sec)
INFO:tensorflow:global_step/sec: 6.89386
INFO:tensorflow:loss = 1.71345, step = 8901 (14.506 sec)
INFO:tensorflow:global_step/sec: 6.87358
INFO:tensorflow:loss = 2.07762, step = 9001 (14.548 sec)
INFO:tensorflow:global_step/sec: 6.88136
INFO:tensorflow:loss = 2.14198, step = 9101 (14.532 sec)
INFO:tensorflow:global_step/sec: 6.68367
INFO:tensorflow:loss = 3.31467, step = 9201 (14.962 sec)
INFO:tensorflow:global_step/sec: 6.54802
INFO:tensorflow:loss = 3.09743, step = 9301 (15.272 sec)
INFO:tensorflow:global_step/sec: 6.80104
INFO:tensorflow:loss = 3.22471, step = 9401 (14.704 sec)
INFO:tensorflow:global_step/sec: 6.95361
INFO:tensorflow:loss = 3.13789, step = 9501 (14.381 sec)
INFO:tensorflow:global_step/sec: 6.91033
INFO:tensorflow:loss = 3.20369, step = 9601 (14.471 sec)
INFO:tensorflow:global_step/sec: 6.92991
INFO:tensorflow:loss = 3.36464, step = 9701 (14.430 sec)
INFO:tensorflow:global_step/sec: 6.76151
INFO:tensorflow:loss = 3.16024, step = 9801 (14.790 sec)
INFO:tensorflow:global_step/sec: 6.66131
INFO:tensorflow:loss = 3.08757, step = 9901 (15.012 sec)
INFO:tensorflow:Saving checkpoints for 10000 into /tmp/tmpb3eyyydg/model.ckpt.
INFO:tensorflow:Loss for final step: 3.14102.

--------------------------------------------------
Iteration 2
----------------------------------------
Training
----------------------------------------
WARNING:tensorflow:From <ipython-input-28-c9008343d737>: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-28-c9008343d737>: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-28-c9008343d737>: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(...))
INFO:tensorflow:Create CheckpointSaverHook.
INFO:tensorflow:Restoring parameters from /tmp/tmpb3eyyydg/model.ckpt-10000
INFO:tensorflow:Saving checkpoints for 10001 into /tmp/tmpb3eyyydg/model.ckpt.
INFO:tensorflow:loss = 3.02254, step = 10001
INFO:tensorflow:global_step/sec: 6.87455
INFO:tensorflow:loss = 3.13725, step = 10101 (14.547 sec)
INFO:tensorflow:global_step/sec: 6.94521
INFO:tensorflow:loss = 3.20994, step = 10201 (14.398 sec)
INFO:tensorflow:global_step/sec: 6.97284
INFO:tensorflow:loss = 3.22871, step = 10301 (14.341 sec)
INFO:tensorflow:global_step/sec: 6.88516
INFO:tensorflow:loss = 3.22394, step = 10401 (14.524 sec)
INFO:tensorflow:global_step/sec: 6.79148
INFO:tensorflow:loss = 3.12883, step = 10501 (14.724 sec)
INFO:tensorflow:global_step/sec: 6.46741
INFO:tensorflow:loss = 3.04938, step = 10601 (15.462 sec)
INFO:tensorflow:global_step/sec: 6.75263
INFO:tensorflow:loss = 3.06904, step = 10701 (14.809 sec)
INFO:tensorflow:global_step/sec: 6.83355
INFO:tensorflow:loss = 3.09266, step = 10801 (14.634 sec)
INFO:tensorflow:global_step/sec: 6.80697
INFO:tensorflow:loss = 2.99133, step = 10901 (14.691 sec)
INFO:tensorflow:global_step/sec: 6.82539
INFO:tensorflow:loss = 3.12591, step = 11001 (14.651 sec)
INFO:tensorflow:global_step/sec: 6.84007
INFO:tensorflow:loss = 3.30762, step = 11101 (14.620 sec)
INFO:tensorflow:global_step/sec: 6.65386
INFO:tensorflow:loss = 3.07087, step = 11201 (15.029 sec)
INFO:tensorflow:global_step/sec: 6.76419
INFO:tensorflow:loss = 3.07753, step = 11301 (14.784 sec)
INFO:tensorflow:global_step/sec: 6.84286
INFO:tensorflow:loss = 3.01707, step = 11401 (14.614 sec)
INFO:tensorflow:global_step/sec: 6.84529
INFO:tensorflow:loss = 3.06243, step = 11501 (14.609 sec)
INFO:tensorflow:global_step/sec: 6.83676
INFO:tensorflow:loss = 3.08152, step = 11601 (14.627 sec)
INFO:tensorflow:global_step/sec: 6.71521
INFO:tensorflow:loss = 3.1759, step = 11701 (14.892 sec)
INFO:tensorflow:global_step/sec: 6.80408
INFO:tensorflow:loss = 3.08926, step = 11801 (14.697 sec)
INFO:tensorflow:global_step/sec: 6.7007
INFO:tensorflow:loss = 3.14384, step = 11901 (14.924 sec)
INFO:tensorflow:global_step/sec: 6.82601
INFO:tensorflow:loss = 3.0604, step = 12001 (14.650 sec)
INFO:tensorflow:global_step/sec: 6.89824
INFO:tensorflow:loss = 3.07297, step = 12101 (14.496 sec)
INFO:tensorflow:global_step/sec: 6.8611
INFO:tensorflow:loss = 3.183, step = 12201 (14.575 sec)
INFO:tensorflow:global_step/sec: 6.8568
INFO:tensorflow:loss = 3.2714, step = 12301 (14.584 sec)
INFO:tensorflow:global_step/sec: 6.88843
INFO:tensorflow:loss = 3.1505, step = 12401 (14.517 sec)
INFO:tensorflow:global_step/sec: 6.67464
INFO:tensorflow:loss = 3.18656, step = 12501 (14.982 sec)
INFO:tensorflow:global_step/sec: 6.69162
INFO:tensorflow:loss = 3.25563, step = 12601 (14.944 sec)
INFO:tensorflow:global_step/sec: 6.71095
INFO:tensorflow:loss = 3.10958, step = 12701 (14.901 sec)
INFO:tensorflow:global_step/sec: 6.62488
INFO:tensorflow:loss = 3.06234, step = 12801 (15.095 sec)
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-28-c9008343d737> in <module>()
     22     print("Training")
     23     print('-' * 40)
---> 24     nn.fit(x=X, y=y, steps=STEPS, batch_size=BATCH_SIZE)

/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 [ ]: