numeric_columns と categorical_columns を結合し,これを tf.keras.layers.DenseFeatures に入力して,preprocessing_layer とする:
>>> preprocessing_layer = \
... tf.keras.layers.DenseFeatures( categorical_columns + numeric_columns )
preprocessing_layer の機能チェック:
>>> for batch in packed_train_data.take(1):
... print( preprocessing_layer(batch).numpy()[0] )
...
Traceback (most recent call last):
File "", line 2, in
File "/home/pi/venv/lib/python3.7/site-packages/
tensorflow_core/python/keras/engine/base_layer.py",
line 913, in __call__outputs = self.call(cast_inputs, *args, **kwargs)
File "/home/pi/venv/lib/python3.7/site-packages/
tensorflow_core/python/feature_column/dense_features.py",
line 129, in call features)
ValueError: ('We expected a dictionary here. Instead we got: ',
(OrderedDict([
('sex', ),
('class', ),
('deck', ),
('embark_town', ),
('alone', ),
('numeric', )
]),
)
|