In the beginning, I need to say that I am using TF v 1.1.
The code:
import random
import tensorflow as tf
xData = []
yData = []
for _ in range(10000):
x = random.random()
xData.append(x)
y = 2 * x
yData.append(y)
xc = tf.contrib.layers.real_valued_column("")
estimator = tf.contrib.learn.DynamicRnnEstimator(problem_type = constants.ProblemType.LINEAR_REGRESSION,
prediction_type = PredictionType.SINGLE_VALUE,
sequence_feature_columns = [xc],
context_feature_columns = None,
num_units = 5,
cell_type = 'lstm',
optimizer = 'SGD',
learning_rate = '0.1')
def get_train_inputs():
x = tf.constant(xData)
y = tf.constant(yData)
return x, y
estimator.fit(input_fn=get_train_inputs, steps=TRAINING_STEPS)
I got:
AttributeError: 'Tensor' object has no attribute 'get'
here. The same code works for LinearRegressor instead of DynamicRnnEstimator.
WARNING:tensorflow:From E:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dynamic_rnn_estimator.py:724: regression_target (from tensorflow.contrib.layers.python.layers.target_column) is deprecated and will be removed after 2016-11-12. Instructions for updating: This file will be removed after the deprecation date.Please switch to third_party/tensorflow/contrib/learn/python/learn/estimators/head.py WARNING:tensorflow:Using temporary folder as model directory: C:\Users\pavel\AppData\Local\Temp\tmpzy68t_iw
Blockquote
Traceback (most recent call last): File "C:/Users/pavel/PycharmProjects/rnnEstimator/main.py", line 31, in estimator.fit(input_fn=get_train_inputs, steps=1000)
File "E:\Python35\lib\site-packages\tensorflow\python\util\deprecation.py", line 281, in new_func return func(*args, **kwargs)
File "E:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 430, in fit loss = self._train_model(input_fn=input_fn, hooks=hooks)
File "E:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 927, in _train_model model_fn_ops = self._get_train_ops(features, labels)
File "E:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 1132, in _get_train_ops return self._call_model_fn(features, labels, model_fn_lib.ModeKeys.TRAIN)
File "E:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 1103, in _call_model_fn model_fn_results = self._model_fn(features, labels, **kwargs)
File "E:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dynamic_rnn_estimator.py", line 516, in _dynamic_rnn_model_fn sequence_length = features.get(sequence_length_key) AttributeError: 'Tensor' object has no attribute 'get'
Update: Issue in TF repo's