How to normalize features in TensorFlow
TL;DR When using tf.estimator, use the normalizer_fn argument in tf.feature_column.numeric_feature to normalize using the same parameters (mean, std, etc.) for training, evaluation, and serving.
def zscore(col):
mean = 3.04
std = 1.2
return (col — mean)/std
feature_name = ‘total_bedrooms’
normalized_feature = tf.feature_column.numeric_column(
feature_name,
normalizer_fn=zscore)