Here is the official doc.
A layer that produces a dense Tensor based on given feature_columns.
Inherits From: DenseFeatures
tf.keras.layers.DenseFeatures(
feature_columns, trainable=True, name=None, **kwargs
)
This is used in TF example and usually put in keras.Sequential(...) model construction. Like below:
model = tf.keras.Sequential([
feature_layer,
layers.Dense(128, activation='relu'),
layers.Dense(128, activation='relu'),
layers.Dropout(.1),
layers.Dense(1)
])
In my case, I want to use it to transfer my dictionary data type into Tensor format and pass it into model. So I used code like below:
feature_columns = []
bins = [-125, -75, -50, -25, 0, 25, 50, 75, 125]
temp_num = feature_column.numeric_column('temp')
temp_buckets = feature_column.bucketized_column(temp_num, boundaries=bins)
feature_columns.append(temp_buckets)
feature_layer = layers.DenseFeatures(feature_columns)
input = feature_layer(dict(dataframe))
And input is the training data I would feed into model. The question is whether my usage of this DenseFeatures() layer is reasonable. Or this feature_layer has to be in keras.Model class?