|  View source on GitHub | 
Represents real valued or numerical features. (deprecated)
tf.feature_column.numeric_column(
    key,
    shape=(1,),
    default_value=None,
    dtype=tf.dtypes.float32,
    normalizer_fn=None
)
Example:
Assume we have data with two features a and b.
data = {'a': [15, 9, 17, 19, 21, 18, 25, 30],'b': [5.0, 6.4, 10.5, 13.6, 15.7, 19.9, 20.3 , 0.0]}
Let us represent the features a and b as numerical features.
a = tf.feature_column.numeric_column('a')b = tf.feature_column.numeric_column('b')
Feature column describe a set of transformations to the inputs.
For example, to "bucketize" feature a, wrap the a column in a
feature_column.bucketized_column.
Providing 5 bucket boundaries, the bucketized_column api
will bucket this feature in total of 6 buckets.
a_buckets = tf.feature_column.bucketized_column(a,boundaries=[10, 15, 20, 25, 30])
Create a DenseFeatures layer which will apply the transformations
described by the set of tf.feature_column objects:
feature_layer = tf.keras.layers.DenseFeatures([a_buckets, b])print(feature_layer(data))tf.Tensor([[ 0. 0. 1. 0. 0. 0. 5. ][ 1. 0. 0. 0. 0. 0. 6.4][ 0. 0. 1. 0. 0. 0. 10.5][ 0. 0. 1. 0. 0. 0. 13.6][ 0. 0. 0. 1. 0. 0. 15.7][ 0. 0. 1. 0. 0. 0. 19.9][ 0. 0. 0. 0. 1. 0. 20.3][ 0. 0. 0. 0. 0. 1. 0. ]], shape=(8, 7), dtype=float32)
| Args | |
|---|---|
| key | A unique string identifying the input feature. It is used as the column
name and the dictionary key for feature parsing configs, feature Tensorobjects, and feature columns. | 
| shape | An iterable of integers specifies the shape of the Tensor. An
integer can be given which means a single dimensionTensorwith given
width. TheTensorrepresenting the column will have the shape of
[batch_size] +shape. | 
| default_value | A single value compatible with dtypeor an iterable of
values compatible withdtypewhich the column takes on duringtf.Exampleparsing if data is missing. A default value ofNonewill
causetf.io.parse_exampleto fail if an example does not contain this
column. If a single value is provided, the same value will be applied as
the default value for every item. If an iterable of values is provided,
the shape of thedefault_valueshould be equal to the givenshape. | 
| dtype | defines the type of values. Default value is tf.float32. Must be a
non-quantized, real integer or floating point type. | 
| normalizer_fn | If not None, a function that can be used to normalize the
value of the tensor afterdefault_valueis applied for parsing.
Normalizer function takes the inputTensoras its argument, and returns
the outputTensor. (e.g. lambda x: (x - 3.0) / 4.2). Please note that
even though the most common use case of this function is normalization, it
can be used for any kind of Tensorflow transformations. | 
| Returns | |
|---|---|
| A NumericColumn. | 
| Raises | |
|---|---|
| TypeError | if any dimension in shape is not an int | 
| ValueError | if any dimension in shape is not a positive integer | 
| TypeError | if default_valueis an iterable but not compatible withshape | 
| TypeError | if default_valueis not compatible withdtype. | 
| ValueError | if dtypeis not convertible totf.float32. |