tf.feature_column.make_parse_example_spec

tf.feature_column.make_parse_example_spec

tf.feature_column.make_parse_example_spec

make_parse_example_spec(feature_columns)

Defined in tensorflow/python/feature_column/feature_column.py.

Creates parsing spec dictionary from input feature_columns.

The returned dictionary can be used as arg 'features' in tf.parse_example.

Typical usage example:

# Define features and transformations
feature_b = numeric_column(...)
feature_c_bucketized = bucketized_column(numeric_column("feature_c"), ...)
feature_a_x_feature_c = crossed_column(
    columns=["feature_a", feature_c_bucketized], ...)

feature_columns = set(
    [feature_b, feature_c_bucketized, feature_a_x_feature_c])
features = tf.parse_example(
    serialized=serialized_examples,
    features=make_parse_example_spec(feature_columns))

For the above example, make_parse_example_spec would return the dict: { "feature_a": parsing_ops.VarLenFeature(tf.string), "feature_b": parsing_ops.FixedLenFeature([1], dtype=tf.float32), "feature_c": parsing_ops.FixedLenFeature([1], dtype=tf.float32) }

Args:

  • feature_columns: An iterable containing all feature columns. All items should be instances of classes derived from _FeatureColumn.

Returns:

A dict mapping each feature key to a FixedLenFeature or VarLenFeature value.

Raises:

  • ValueError: If any of the given feature_columns is not a _FeatureColumn instance.

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/feature_column/make_parse_example_spec

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部