In [20]:
# 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="Adam",
)
# 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 [ ]:
# PARAMETERS
LEARNING_RATE = 0.0001
BATCH_SIZE = 64
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)
# 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)
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 0x7f6340404438>}
WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpv058jrrr
--------------------------------------------------
Iteration 1
----------------------------------------
Training
----------------------------------------
WARNING:tensorflow:From <ipython-input-21-9bed8961c2ed>: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-21-9bed8961c2ed>: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-21-9bed8961c2ed>: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/tmpv058jrrr/model.ckpt.
INFO:tensorflow:loss = 3.66103, step = 1
INFO:tensorflow:global_step/sec: 11.2895
INFO:tensorflow:loss = 3.37729, step = 101 (8.859 sec)
INFO:tensorflow:global_step/sec: 11.5884
INFO:tensorflow:loss = 3.15746, step = 201 (8.629 sec)
INFO:tensorflow:global_step/sec: 11.582
INFO:tensorflow:loss = 2.96604, step = 301 (8.634 sec)
INFO:tensorflow:global_step/sec: 11.2301
INFO:tensorflow:loss = 2.93641, step = 401 (8.905 sec)
INFO:tensorflow:global_step/sec: 11.5129
INFO:tensorflow:loss = 3.12586, step = 501 (8.686 sec)
INFO:tensorflow:global_step/sec: 11.6271
INFO:tensorflow:loss = 3.16031, step = 601 (8.601 sec)
INFO:tensorflow:global_step/sec: 11.7331
INFO:tensorflow:loss = 2.9931, step = 701 (8.523 sec)
INFO:tensorflow:global_step/sec: 11.6664
INFO:tensorflow:loss = 2.91062, step = 801 (8.572 sec)
INFO:tensorflow:global_step/sec: 11.7135
INFO:tensorflow:loss = 2.90223, step = 901 (8.537 sec)
INFO:tensorflow:global_step/sec: 11.6527
INFO:tensorflow:loss = 2.80358, step = 1001 (8.582 sec)
INFO:tensorflow:global_step/sec: 11.473
INFO:tensorflow:loss = 2.79793, step = 1101 (8.716 sec)
INFO:tensorflow:global_step/sec: 11.1777
INFO:tensorflow:loss = 2.77893, step = 1201 (8.946 sec)
INFO:tensorflow:global_step/sec: 11.2672
INFO:tensorflow:loss = 2.50716, step = 1301 (8.875 sec)
INFO:tensorflow:global_step/sec: 11.644
INFO:tensorflow:loss = 2.57156, step = 1401 (8.588 sec)
INFO:tensorflow:global_step/sec: 11.7005
INFO:tensorflow:loss = 2.85685, step = 1501 (8.547 sec)
INFO:tensorflow:global_step/sec: 11.71
INFO:tensorflow:loss = 2.56468, step = 1601 (8.540 sec)
INFO:tensorflow:global_step/sec: 11.6626
INFO:tensorflow:loss = 2.62178, step = 1701 (8.574 sec)
INFO:tensorflow:global_step/sec: 11.6425
INFO:tensorflow:loss = 2.66826, step = 1801 (8.589 sec)
INFO:tensorflow:global_step/sec: 11.7016
INFO:tensorflow:loss = 2.46299, step = 1901 (8.546 sec)
INFO:tensorflow:global_step/sec: 11.6373
INFO:tensorflow:loss = 2.43819, step = 2001 (8.593 sec)
INFO:tensorflow:global_step/sec: 11.5622
INFO:tensorflow:loss = 2.51855, step = 2101 (8.649 sec)
INFO:tensorflow:global_step/sec: 10.9022
INFO:tensorflow:loss = 2.55958, step = 2201 (9.173 sec)
INFO:tensorflow:global_step/sec: 11.3409
INFO:tensorflow:loss = 2.34067, step = 2301 (8.818 sec)
INFO:tensorflow:global_step/sec: 11.6938
INFO:tensorflow:loss = 2.45406, step = 2401 (8.552 sec)
INFO:tensorflow:global_step/sec: 11.5818
INFO:tensorflow:loss = 2.34224, step = 2501 (8.634 sec)
INFO:tensorflow:global_step/sec: 11.6169
INFO:tensorflow:loss = 2.20766, step = 2601 (8.608 sec)
INFO:tensorflow:global_step/sec: 11.5974
INFO:tensorflow:loss = 2.26062, step = 2701 (8.623 sec)
INFO:tensorflow:global_step/sec: 10.9243
INFO:tensorflow:loss = 2.49485, step = 2801 (9.154 sec)
INFO:tensorflow:global_step/sec: 10.6286
INFO:tensorflow:loss = 2.3821, step = 2901 (9.409 sec)
INFO:tensorflow:global_step/sec: 10.6501
INFO:tensorflow:loss = 2.64364, step = 3001 (9.390 sec)
INFO:tensorflow:global_step/sec: 10.6572
INFO:tensorflow:loss = 2.06548, step = 3101 (9.383 sec)
INFO:tensorflow:global_step/sec: 10.5916
INFO:tensorflow:loss = 2.43006, step = 3201 (9.441 sec)
INFO:tensorflow:global_step/sec: 10.4789
INFO:tensorflow:loss = 2.46145, step = 3301 (9.543 sec)
INFO:tensorflow:global_step/sec: 10.4877
INFO:tensorflow:loss = 2.42083, step = 3401 (9.535 sec)
INFO:tensorflow:global_step/sec: 10.6503
INFO:tensorflow:loss = 2.18245, step = 3501 (9.389 sec)
INFO:tensorflow:global_step/sec: 10.8096
INFO:tensorflow:loss = 2.4703, step = 3601 (9.251 sec)
INFO:tensorflow:global_step/sec: 10.3884
INFO:tensorflow:loss = 2.30896, step = 3701 (9.626 sec)
INFO:tensorflow:global_step/sec: 10.7416
INFO:tensorflow:loss = 2.47356, step = 3801 (9.310 sec)
INFO:tensorflow:global_step/sec: 10.798
INFO:tensorflow:loss = 2.31417, step = 3901 (9.261 sec)
INFO:tensorflow:global_step/sec: 10.8014
INFO:tensorflow:loss = 2.32599, step = 4001 (9.258 sec)
INFO:tensorflow:global_step/sec: 10.8068
INFO:tensorflow:loss = 2.29042, step = 4101 (9.253 sec)
INFO:tensorflow:global_step/sec: 10.8639
INFO:tensorflow:loss = 2.09807, step = 4201 (9.205 sec)
INFO:tensorflow:global_step/sec: 10.8346
INFO:tensorflow:loss = 2.34485, step = 4301 (9.230 sec)
INFO:tensorflow:global_step/sec: 10.8815
INFO:tensorflow:loss = 2.35021, step = 4401 (9.190 sec)
INFO:tensorflow:global_step/sec: 10.7868
INFO:tensorflow:loss = 2.30791, step = 4501 (9.271 sec)
INFO:tensorflow:global_step/sec: 10.7074
INFO:tensorflow:loss = 2.34023, step = 4601 (9.339 sec)
INFO:tensorflow:global_step/sec: 10.8376
INFO:tensorflow:loss = 2.33809, step = 4701 (9.227 sec)
INFO:tensorflow:global_step/sec: 10.8173
INFO:tensorflow:loss = 2.52525, step = 4801 (9.244 sec)
INFO:tensorflow:global_step/sec: 10.7693
INFO:tensorflow:loss = 2.41627, step = 4901 (9.286 sec)
INFO:tensorflow:global_step/sec: 10.8616
INFO:tensorflow:loss = 2.36729, step = 5001 (9.207 sec)
INFO:tensorflow:global_step/sec: 10.824
INFO:tensorflow:loss = 2.09699, step = 5101 (9.239 sec)
INFO:tensorflow:global_step/sec: 10.2371
INFO:tensorflow:loss = 2.43144, step = 5201 (9.768 sec)
INFO:tensorflow:global_step/sec: 10.8125
INFO:tensorflow:loss = 2.25776, step = 5301 (9.249 sec)
INFO:tensorflow:global_step/sec: 10.8294
INFO:tensorflow:loss = 1.99604, step = 5401 (9.234 sec)
INFO:tensorflow:global_step/sec: 10.8879
INFO:tensorflow:loss = 2.1877, step = 5501 (9.184 sec)
INFO:tensorflow:global_step/sec: 10.8269
INFO:tensorflow:loss = 2.30209, step = 5601 (9.236 sec)
INFO:tensorflow:global_step/sec: 11.0118
INFO:tensorflow:loss = 2.02678, step = 5701 (9.081 sec)
INFO:tensorflow:global_step/sec: 10.9669
INFO:tensorflow:loss = 2.50862, step = 5801 (9.118 sec)
INFO:tensorflow:global_step/sec: 10.6967
INFO:tensorflow:loss = 1.94713, step = 5901 (9.349 sec)
INFO:tensorflow:global_step/sec: 10.7031
INFO:tensorflow:loss = 2.16625, step = 6001 (9.343 sec)
INFO:tensorflow:global_step/sec: 10.9272
INFO:tensorflow:loss = 2.39839, step = 6101 (9.152 sec)
INFO:tensorflow:global_step/sec: 11.0091
INFO:tensorflow:loss = 2.42857, step = 6201 (9.083 sec)
INFO:tensorflow:global_step/sec: 11.021
INFO:tensorflow:loss = 2.26308, step = 6301 (9.074 sec)
INFO:tensorflow:global_step/sec: 10.6196
INFO:tensorflow:loss = 2.30955, step = 6401 (9.416 sec)
INFO:tensorflow:global_step/sec: 10.8693
INFO:tensorflow:loss = 2.32297, step = 6501 (9.200 sec)
INFO:tensorflow:global_step/sec: 10.9752
INFO:tensorflow:loss = 2.14748, step = 6601 (9.111 sec)
INFO:tensorflow:Saving checkpoints for 6629 into /tmp/tmpv058jrrr/model.ckpt.
INFO:tensorflow:global_step/sec: 9.83727
INFO:tensorflow:loss = 2.42613, step = 6701 (10.165 sec)
INFO:tensorflow:global_step/sec: 11.1101
INFO:tensorflow:loss = 2.20095, step = 6801 (9.001 sec)
INFO:tensorflow:global_step/sec: 11.0776
INFO:tensorflow:loss = 2.04425, step = 6901 (9.027 sec)
INFO:tensorflow:global_step/sec: 10.7492
INFO:tensorflow:loss = 2.12069, step = 7001 (9.303 sec)
INFO:tensorflow:global_step/sec: 11.0723
INFO:tensorflow:loss = 2.10133, step = 7101 (9.031 sec)
INFO:tensorflow:global_step/sec: 11.1374
INFO:tensorflow:loss = 2.07391, step = 7201 (8.979 sec)
INFO:tensorflow:global_step/sec: 11.0898
INFO:tensorflow:loss = 2.14531, step = 7301 (9.017 sec)
INFO:tensorflow:global_step/sec: 11.1337
INFO:tensorflow:loss = 2.38488, step = 7401 (8.982 sec)
INFO:tensorflow:global_step/sec: 10.8713
INFO:tensorflow:loss = 1.92753, step = 7501 (9.199 sec)
INFO:tensorflow:global_step/sec: 10.9749
INFO:tensorflow:loss = 2.45484, step = 7601 (9.112 sec)
INFO:tensorflow:global_step/sec: 11.1171
INFO:tensorflow:loss = 2.01582, step = 7701 (8.995 sec)
INFO:tensorflow:global_step/sec: 11.1118
INFO:tensorflow:loss = 2.10858, step = 7801 (8.999 sec)
INFO:tensorflow:global_step/sec: 11.0031
INFO:tensorflow:loss = 2.3713, step = 7901 (9.088 sec)
INFO:tensorflow:global_step/sec: 11.1927
INFO:tensorflow:loss = 2.102, step = 8001 (8.934 sec)
INFO:tensorflow:global_step/sec: 11.2172
INFO:tensorflow:loss = 2.13666, step = 8101 (8.915 sec)
INFO:tensorflow:global_step/sec: 11.1975
INFO:tensorflow:loss = 2.08375, step = 8201 (8.930 sec)
INFO:tensorflow:global_step/sec: 11.1649
INFO:tensorflow:loss = 2.10164, step = 8301 (8.957 sec)
INFO:tensorflow:global_step/sec: 11.1456
INFO:tensorflow:loss = 2.03846, step = 8401 (8.972 sec)
INFO:tensorflow:global_step/sec: 11.1988
INFO:tensorflow:loss = 2.17244, step = 8501 (8.930 sec)
INFO:tensorflow:global_step/sec: 10.9788
INFO:tensorflow:loss = 2.18528, step = 8601 (9.108 sec)
INFO:tensorflow:global_step/sec: 10.8119
INFO:tensorflow:loss = 2.23051, step = 8701 (9.249 sec)
INFO:tensorflow:global_step/sec: 10.9493
INFO:tensorflow:loss = 1.99174, step = 8801 (9.133 sec)
INFO:tensorflow:global_step/sec: 10.8323
INFO:tensorflow:loss = 2.05067, step = 8901 (9.232 sec)
INFO:tensorflow:global_step/sec: 10.7575
INFO:tensorflow:loss = 2.52981, step = 9001 (9.296 sec)
INFO:tensorflow:global_step/sec: 10.9257
INFO:tensorflow:loss = 2.00066, step = 9101 (9.153 sec)
INFO:tensorflow:global_step/sec: 10.9988
INFO:tensorflow:loss = 2.09248, step = 9201 (9.092 sec)
INFO:tensorflow:global_step/sec: 11.0873
INFO:tensorflow:loss = 2.4681, step = 9301 (9.019 sec)
INFO:tensorflow:global_step/sec: 10.6448
INFO:tensorflow:loss = 2.04558, step = 9401 (9.394 sec)
INFO:tensorflow:global_step/sec: 10.0077
INFO:tensorflow:loss = 2.12076, step = 9501 (9.992 sec)
INFO:tensorflow:global_step/sec: 10.0873
INFO:tensorflow:loss = 2.2738, step = 9601 (9.914 sec)
INFO:tensorflow:global_step/sec: 10.1466
INFO:tensorflow:loss = 2.10487, step = 9701 (9.856 sec)
INFO:tensorflow:global_step/sec: 11.089
INFO:tensorflow:loss = 1.94769, step = 9801 (9.018 sec)
INFO:tensorflow:global_step/sec: 11.0463
INFO:tensorflow:loss = 1.98474, step = 9901 (9.053 sec)
INFO:tensorflow:Saving checkpoints for 10000 into /tmp/tmpv058jrrr/model.ckpt.
INFO:tensorflow:Loss for final step: 2.29288.
--------------------------------------------------
Iteration 2
----------------------------------------
Training
----------------------------------------
WARNING:tensorflow:From <ipython-input-21-9bed8961c2ed>: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-21-9bed8961c2ed>: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-21-9bed8961c2ed>: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/tmpv058jrrr/model.ckpt-10000
INFO:tensorflow:Saving checkpoints for 10001 into /tmp/tmpv058jrrr/model.ckpt.
INFO:tensorflow:loss = 2.00153, step = 10001
INFO:tensorflow:global_step/sec: 10.7712
INFO:tensorflow:loss = 2.46656, step = 10101 (9.285 sec)
INFO:tensorflow:global_step/sec: 11.5048
INFO:tensorflow:loss = 2.3119, step = 10201 (8.692 sec)
INFO:tensorflow:global_step/sec: 11.2838
INFO:tensorflow:loss = 2.23369, step = 10301 (8.862 sec)
INFO:tensorflow:global_step/sec: 11.3702
INFO:tensorflow:loss = 2.03032, step = 10401 (8.795 sec)
INFO:tensorflow:global_step/sec: 11.4277
INFO:tensorflow:loss = 2.08923, step = 10501 (8.751 sec)
INFO:tensorflow:global_step/sec: 11.7067
INFO:tensorflow:loss = 2.01718, step = 10601 (8.542 sec)
INFO:tensorflow:global_step/sec: 11.5647
INFO:tensorflow:loss = 1.87282, step = 10701 (8.647 sec)
INFO:tensorflow:global_step/sec: 11.5511
INFO:tensorflow:loss = 2.14904, step = 10801 (8.657 sec)
INFO:tensorflow:global_step/sec: 11.5988
INFO:tensorflow:loss = 2.09514, step = 10901 (8.622 sec)
INFO:tensorflow:global_step/sec: 11.6561
INFO:tensorflow:loss = 2.13615, step = 11001 (8.579 sec)
INFO:tensorflow:global_step/sec: 11.4744
INFO:tensorflow:loss = 2.12409, step = 11101 (8.715 sec)
INFO:tensorflow:global_step/sec: 11.5988
INFO:tensorflow:loss = 2.31468, step = 11201 (8.622 sec)
INFO:tensorflow:global_step/sec: 11.3229
INFO:tensorflow:loss = 2.02509, step = 11301 (8.832 sec)
INFO:tensorflow:global_step/sec: 11.2527
INFO:tensorflow:loss = 2.04172, step = 11401 (8.887 sec)
INFO:tensorflow:global_step/sec: 11.4018
INFO:tensorflow:loss = 2.34327, step = 11501 (8.770 sec)
INFO:tensorflow:global_step/sec: 11.4742
INFO:tensorflow:loss = 2.16391, step = 11601 (8.715 sec)
INFO:tensorflow:global_step/sec: 10.8816
INFO:tensorflow:loss = 2.19522, step = 11701 (9.190 sec)
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 [ ]:
Content source: mari-linhares/tensorflow-workshop
Similar notebooks: