Generally a single example in training data is described with FeatureColumns.
At the first layer of the model, this column oriented data should be converted
to a single Tensor.
A mapping from key to tensors. _FeatureColumns look up via these
keys. For example numeric_column('price') will look at 'price' key in
this dict. Values can be a SparseTensor or a Tensor depends on
corresponding _FeatureColumn.
feature_columns
An iterable containing the FeatureColumns to use as inputs
to your model. All items should be instances of classes derived from
_DenseColumn such as numeric_column, embedding_column,
bucketized_column, indicator_column. If you have categorical features,
you can wrap them with an embedding_column or indicator_column.
weight_collections
A list of collection names to which the Variable will be
added. Note that variables will also be added to collections
tf.GraphKeys.GLOBAL_VARIABLES and ops.GraphKeys.MODEL_VARIABLES.
trainable
If True also add the variable to the graph collection
GraphKeys.TRAINABLE_VARIABLES (see tf.Variable).
cols_to_vars
If not None, must be a dictionary that will be filled with a
mapping from _FeatureColumn to list of Variables. For example, after
the call, we might have cols_to_vars = {_EmbeddingColumn(
categorical_column=_HashedCategoricalColumn( key='sparse_feature',
hash_bucket_size=5, dtype=tf.string), dimension=10): [
cols_to_output_tensors
If not None, must be a dictionary that will be
filled with a mapping from '_FeatureColumn' to the associated output
Tensors.
Returns
A Tensor which represents input layer of a model. Its shape
is (batch_size, first_layer_dimension) and its dtype is float32.
first_layer_dimension is determined based on given feature_columns.
Raises
ValueError
if an item in feature_columns is not a _DenseColumn.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.feature_column.input_layer\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.py#L145-L214) |\n\nReturns a dense `Tensor` as input layer based on given `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.compat.v1.feature_column.input_layer(\n features,\n feature_columns,\n weight_collections=None,\n trainable=True,\n cols_to_vars=None,\n cols_to_output_tensors=None\n )\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\nGenerally a single example in training data is described with FeatureColumns.\nAt the first layer of the model, this column oriented data should be converted\nto a single `Tensor`.\n\n#### Example:\n\n price = numeric_column('price')\n keywords_embedded = embedding_column(\n categorical_column_with_hash_bucket(\"keywords\", 10K), dimensions=16)\n columns = [price, keywords_embedded, ...]\n features = tf.io.parse_example(..., features=make_parse_example_spec(columns))\n dense_tensor = input_layer(features, columns)\n for units in [128, 64, 32]:\n dense_tensor = tf.compat.v1.layers.dense(dense_tensor, units, tf.nn.relu)\n prediction = tf.compat.v1.layers.dense(dense_tensor, 1)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `features` | A mapping from key to tensors. `_FeatureColumn`s look up via these keys. For example `numeric_column('price')` will look at 'price' key in this dict. Values can be a `SparseTensor` or a `Tensor` depends on corresponding `_FeatureColumn`. |\n| `feature_columns` | An iterable containing the FeatureColumns to use as inputs to your model. All items should be instances of classes derived from `_DenseColumn` such as `numeric_column`, `embedding_column`, `bucketized_column`, `indicator_column`. If you have categorical features, you can wrap them with an `embedding_column` or `indicator_column`. |\n| `weight_collections` | A list of collection names to which the Variable will be added. Note that variables will also be added to collections `tf.GraphKeys.GLOBAL_VARIABLES` and `ops.GraphKeys.MODEL_VARIABLES`. |\n| `trainable` | If `True` also add the variable to the graph collection `GraphKeys.TRAINABLE_VARIABLES` (see [`tf.Variable`](../../../../tf/Variable)). |\n| `cols_to_vars` | If not `None`, must be a dictionary that will be filled with a mapping from `_FeatureColumn` to list of `Variable`s. For example, after the call, we might have cols_to_vars = {_EmbeddingColumn( categorical_column=_HashedCategoricalColumn( key='sparse_feature', hash_bucket_size=5, dtype=tf.string), dimension=10): \\[ |\n| `cols_to_output_tensors` | If not `None`, must be a dictionary that will be filled with a mapping from '_FeatureColumn' to the associated output `Tensor`s. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor` which represents input layer of a model. Its shape is (batch_size, first_layer_dimension) and its dtype is `float32`. first_layer_dimension is determined based on given `feature_columns`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|----------------------------------------------------------|\n| `ValueError` | if an item in `feature_columns` is not a `_DenseColumn`. |\n\n\u003cbr /\u003e"]]