【发布时间】:2020-03-20 15:21:45
【问题描述】:
我正在尝试使用 Tensorflows 线性分类器估计器来预测未来的平均温度。目标特征是 float64 类型,其他用于预测平均温度的特征也是 float64。
以下是我用来将特征转换为 tf 数值列的方法。
for feature_name in NUMERIC_COLUMNS:
feature_columns.append(tf.feature_column.numeric_column(
feature_name, dtype=tf.float64))
我创建如图所示的线性估计器
feature_columns=feature_columns, n_classes=4)
在训练模型时出现以下错误。
WARNING:tensorflow:Layer linear/linear_model is casting an input tensor from
dtype float64 to the layer's dtype of float32,
which is new behavior in TensorFlow 2. The layer has dtype float32
because it's dtype defaults to floatx.
Exception has occurred: ValueError
Labels dtype should be integer. Instead got <dtype: 'float64'>.
我很难理解为什么要考虑我明确表示我希望所有功能都是 float64 类型。
【问题讨论】:
-
这是整个错误信息吗?请提供minimal reproducible example。
-
@AMC 我已经更新了这个,我相信它现在可以重现了。如果您需要更多信息,请告诉我。
标签: python tensorflow data-science