tf.contrib.layers.create_feature_spec_for_parsing
Stay organized with collections
Save and categorize content based on your preferences.
Helper that prepares features config from input feature_columns.
tf.contrib.layers.create_feature_spec_for_parsing(
feature_columns
)
The returned feature config can be used as arg 'features' in tf.parse_example.
Typical usage example:
# Define features and transformations
feature_a = sparse_column_with_vocabulary_file(...)
feature_b = real_valued_column(...)
feature_c_bucketized = bucketized_column(real_valued_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])
batch_examples = tf.io.parse_example(
serialized=serialized_examples,
features=create_feature_spec_for_parsing(feature_columns))
For the above example, create_feature_spec_for_parsing 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 the feature columns. All items
should be instances of classes derived from _FeatureColumn, unless
feature_columns is a dict -- in which case, this should be true of all
values in the dict.
|
Returns |
A dict mapping feature keys to FixedLenFeature or VarLenFeature values.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.layers.create_feature_spec_for_parsing\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/layers/python/layers/feature_column.py#L2581-L2625) |\n\nHelper that prepares features config from input feature_columns. \n\n tf.contrib.layers.create_feature_spec_for_parsing(\n feature_columns\n )\n\nThe returned feature config can be used as arg 'features' in tf.parse_example.\n\n#### Typical usage example:\n\n # Define features and transformations\n feature_a = sparse_column_with_vocabulary_file(...)\n feature_b = real_valued_column(...)\n feature_c_bucketized = bucketized_column(real_valued_column(\"feature_c\"), ...)\n feature_a_x_feature_c = crossed_column(\n columns=[feature_a, feature_c_bucketized], ...)\n\n feature_columns = set(\n [feature_b, feature_c_bucketized, feature_a_x_feature_c])\n batch_examples = tf.io.parse_example(\n serialized=serialized_examples,\n features=create_feature_spec_for_parsing(feature_columns))\n\nFor the above example, create_feature_spec_for_parsing would return the dict:\n{\n\"feature_a\": parsing_ops.VarLenFeature(tf.string),\n\"feature_b\": parsing_ops.FixedLenFeature(\\[1\\], dtype=tf.float32),\n\"feature_c\": parsing_ops.FixedLenFeature(\\[1\\], dtype=tf.float32)\n}\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `feature_columns` | An iterable containing all the feature columns. All items should be instances of classes derived from _FeatureColumn, unless feature_columns is a dict -- in which case, this should be true of all values in the dict. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A dict mapping feature keys to FixedLenFeature or VarLenFeature values. ||\n\n\u003cbr /\u003e"]]