The returned dictionary can be used as arg 'features' in
tf.io.parse_example.
Typical usage example:
# Define features and transformationsfeature_a=tf.feature_column.categorical_column_with_vocabulary_file(...)feature_b=tf.feature_column.numeric_column(...)feature_c_bucketized=tf.feature_column.bucketized_column(tf.feature_column.numeric_column("feature_c"),...)feature_a_x_feature_c=tf.feature_column.crossed_column(columns=["feature_a",feature_c_bucketized],...)feature_columns=set([feature_b,feature_c_bucketized,feature_a_x_feature_c])features=tf.io.parse_example(serialized=serialized_examples,features=tf.feature_column.make_parse_example_spec(feature_columns))
For the above example, make_parse_example_spec would return the dict:
[[["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 2024-04-26 UTC."],[],[],null,["# tf.feature_column.make_parse_example_spec\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/feature_column/feature_column_v2.py#L370-L432) |\n\nCreates parsing spec dictionary from input feature_columns. (deprecated)\n| **Warning:** tf.feature_column is not recommended for new code. Instead, feature preprocessing can be done directly using either [Keras preprocessing\nlayers](https://www.tensorflow.org/guide/migrate/migrating_feature_columns) or through the one-stop utility [`tf.keras.utils.FeatureSpace`](https://www.tensorflow.org/api_docs/python/tf/keras/utils/FeatureSpace) built on top of them. See the [migration guide](https://tensorflow.org/guide/migrate) for details. \n\n tf.feature_column.make_parse_example_spec(\n feature_columns\n )\n\n### Used in the notebooks\n\n| Used in the guide |\n|------------------------------------------------------------|\n| - [Estimators](https://www.tensorflow.org/guide/estimator) |\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use Keras preprocessing layers instead, either directly or via the [`tf.keras.utils.FeatureSpace`](../../tf/keras/utils/FeatureSpace) utility. Each of `tf.feature_column.*` has a functional equivalent in `tf.keras.layers` for feature preprocessing when training a Keras model.\n\nThe returned dictionary can be used as arg 'features' in\n[`tf.io.parse_example`](../../tf/io/parse_example).\n\n#### Typical usage example:\n\n # Define features and transformations\n feature_a = tf.feature_column.categorical_column_with_vocabulary_file(...)\n feature_b = tf.feature_column.numeric_column(...)\n feature_c_bucketized = tf.feature_column.bucketized_column(\n tf.feature_column.numeric_column(\"feature_c\"), ...)\n feature_a_x_feature_c = tf.feature_column.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 features = tf.io.parse_example(\n serialized=serialized_examples,\n features=tf.feature_column.make_parse_example_spec(feature_columns))\n\nFor the above example, make_parse_example_spec would return the dict: \n\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 feature columns. All items should be instances of classes derived from `FeatureColumn`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A dict mapping each feature key to a `FixedLenFeature` or `VarLenFeature` value. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|--------------------------------------------------------------------------|\n| `ValueError` | If any of the given `feature_columns` is not a `FeatureColumn` instance. |\n\n\u003cbr /\u003e"]]