我正在使用Tensorflow的Dataset API创建基本数据集,并将其用作罐装RNNEstimator的输入,如下所示(请注意,为简洁起见,有些行已省略:
sequence_feature_colums = [tf.contrib.feature_column.sequence_numeric_column("price")]
estimator = tf.contrib.estimator.RNNEstimator(
head=tf.contrib.estimator.regression_head(),
sequence_feature_columns=sequence_feature_colums)
dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels))
estimator.train(input_fn=lambda:return dataset)
但是我在调用train
时看到以下错误:
...
File "/Users/luke/virtualenvs/smp-rnn/lib/python3.6/site-packages/tensorflow/contrib/feature_column/python/feature_column/sequence_feature_column.py", line 497, in _get_sequence_dense_tensor
sp_tensor, default_value=self.default_value)
File "/Users/luke/virtualenvs/smp-rnn/lib/python3.6/site-packages/tensorflow/python/ops/sparse_ops.py", line 1449, in sparse_tensor_to_dense
sp_input = _convert_to_sparse_tensor(sp_input)
File "/Users/luke/virtualenvs/smp-rnn/lib/python3.6/site-packages/tensorflow/python/ops/sparse_ops.py", line 68, in _convert_to_sparse_tensor
raise TypeError("Input must be a SparseTensor.")
TypeError: Input must be a SparseTensor.
我在这里做错了什么?这是一个非常简单的示例,遵循使用Estimators的标准步骤,因此我不确定我在代码中的哪个位置决定 not 使用SparseTensor。