tf.contrib.layers.bucketized_column如何运作?

时间:2017-04-05 14:02:35

标签: tensorflow

我想弄清楚如何使用

age = tf.contrib.layers.real_valued_column("age")
age_buckets = tf.contrib.layers.bucketized_column(age, boundaries=[18, 25, 30, 35, 40, 45, 50, 55, 60, 65])

https://www.tensorflow.org/tutorials/wide中解决。

1 个答案:

答案 0 :(得分:1)

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/layers/python/layers/feature_column.py

中定义为评论的一个示例用法

从该文件复制:

  age_column = real_valued_column("age")
  bucketized_age_column = bucketized_column(
      source_column=age_column,
      boundaries=[18, 25, 30, 35, 40, 45, 50, 55, 60, 65])
  first_layer = input_from_feature_columns(...,
      feature_columns=[..., bucketized_age_column])
  second_layer = fully_connected(first_layer, ...)

  # For linear models
  predicitions, _, _ = weighted_sum_from_feature_columns(...,
      feature_columns=[..., bucketized_age_column])