来自tensorflow估算器RNNClassifier的ValueError与gcloud ml-engine作业

问题描述 投票:0回答:1

我正在处理task.py文件以提交gcloud MLEngine作业。以前我成功地使用tensorflow.estimator.DNNClassifier来提交包含我的数据的作业(其中包含8列连续数值数据的加密货币价格和数量;没有分类)。

我现在已切换到tensorflow贡献估计器RNNClassifier。这是我相关部分的当前代码:

def get_feature_columns():
  return [
      tf.feature_column.numeric_column(feature, shape=(1,))
      for feature in column_names[:len(column_names)-1]
  ]

def build_estimator(config, learning_rate, num_units):
  return tf.contrib.estimator.RNNClassifier(
    sequence_feature_columns=get_feature_columns(),
    num_units=num_units,
    cell_type='lstm',
    rnn_cell_fn=None,
    optimizer=tf.train.AdamOptimizer(learning_rate=learning_rate),
    config=config)

estimator = build_estimator(
    config=run_config,
    learning_rate=args.learning_rate,
    num_units=[32, 16])

tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec)

但是,我得到以下ValueError:

ValueError: All feature_columns must be of type _SequenceDenseColumn. You can wrap a sequence_categorical_column with an embedding_column or indicator_column. Given (type <class 'tensorflow.python.feature_column.feature_column_v2.NumericColumn'>): NumericColumn(key='LTCUSD_close', shape=(1,), default_value=None, dtype=tf.float32, normalizer_fn=None)

我不明白这一点,因为数据不是绝对的。

tensorflow lstm gcloud recurrent-neural-network tensorflow-estimator
1个回答
0
投票

你得到这个错误,因为你使用数字特征列,而这种估计只能接受序列特征列,你可以在init function上看到它。

因此,您不必使用数字列,而必须使用sequence_numeric_column

© www.soinside.com 2019 - 2024. All rights reserved.