我混合使用分类输入和连续输入。分类输入不是二进制的,因此需要一键编码。您如何为张量流设置这种情况?
答案 0 :(得分:0)
您可以使用功能列。 Tensorflow文档是开始搜索答案的最佳位置:
要创建要素列,请从tf.feature_column模块中调用函数。本文档介绍了该模块中的九种功能。如下图所示,所有九个函数都返回Categorical-Column或Dense-Column对象,bucketized_column除外,后者从这两个类继承:
要将类别变量的结果与数字变量结合起来,可以使用结合了两种类型特征的“深度和广度”模型:
https://www.tensorflow.org/api_docs/python/tf/estimator/DNNLinearCombinedClassifier
for each column in dnn_feature_columns + linear_feature_columns:
- if column is a _CategoricalColumn, a feature with key=column.name whose value is a SparseTensor.
- if column is a _WeightedCategoricalColumn, two features: the first with key the id column name, the second with key the weight column name. Both features' value must be a SparseTensor.
- if column is a _DenseColumn, a feature with key=column.name whose value is a Tensor.