Tensorflow自定义估算器:“系列”对象是可变的,因此无法进行哈希处理

时间:2018-06-29 09:28:07

标签: python tensorflow

尝试像这样在Tensorflow中创建自定义分类器

def my_model_fn(
features, # This is batch_features from input_fn
labels,   # This is batch_labels from input_fn
mode,     # An instance of tf.estimator.ModeKeys
params    # Additional configuration
):  

    input_layer = tf.feature_column.input_layer(features,                                             
                               feature_columns=params['feature_columns'])

(...)

其中params['feature_columns']的定义如下,其类型为_NumericColumn

feature_columns = [
   tf.feature_column.numeric_column(training_examples['x'])
   ]

params={'feature_columns': feature_columns, 'n_outputs': 1}    

但是,当我尝试构建模型时,

#construct model
model = tf.estimator.Estimator(
    model_fn=my_model_fn,
    model_dir='tensor_custom',
    params=params
    )

我收到以下错误

TypeError: 'Series' objects are mutable, thus they cannot be hashed

我不了解; docs建议我应该能够将_NumericColumn传递给feature_columns参数?

我想我在概念上缺少一些东西,但不确定是什么。任何帮助将不胜感激!

0 个答案:

没有答案