tf.feature_column.numeric_column(
key,
shape=(1,),
default_value=None,
dtype=tf.dtypes.float32,
normalizer_fn=None
)
Defined in tensorflow/python/feature_column/feature_column_v2.py.
Represents real valued or numerical features.
Example:
price = numeric_column('price')
columns = [price, ...]
features = tf.parse_example(..., features=make_parse_example_spec(columns))
dense_tensor = input_layer(features, columns)
# or
bucketized_price = bucketized_column(price, boundaries=[...])
columns = [bucketized_price, ...]
features = tf.parse_example(..., features=make_parse_example_spec(columns))
linear_prediction = linear_model(features, columns)
Args:
key: A unique string identifying the input feature. It is used as the column name and the dictionary key for feature parsing configs, featureTensorobjects, and feature columns.shape: An iterable of integers specifies the shape of theTensor. 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 withdtypeor an iterable of values compatible withdtypewhich the column takes on duringtf.Exampleparsing if data is missing. A default value ofNonewill causetf.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 istf.float32. Must be a non-quantized, real integer or floating point type.normalizer_fn: If notNone, 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 intValueError: if any dimension in shape is not a positive integerTypeError: ifdefault_valueis an iterable but not compatible withshapeTypeError: ifdefault_valueis not compatible withdtype.ValueError: ifdtypeis not convertible totf.float32.