How to use tensorflow feature_columns as input to a keras model

后端 未结 4 1922
陌清茗
陌清茗 2021-02-13 04:16

Tensorflow\'s feature_columns API is quite useful for non-numerical feature processing. However, the current API doc is more about using feature_columns with tensorflow Estimato

4条回答
  •  误落风尘
    2021-02-13 04:55

    If you use tensorflow dataset API, that code could do well.

    featurlayer = keras.layers.DenseFeatures(feature_columns=feature_columns)
    train_dataset = train_dataset.map(lambda x, y: (featurlayer(x), y))
    test_dataset = test_dataset.map(lambda x, y: (featurlayer(x), y))
    
    model.fit(train_dataset, epochs=, steps_per_epoch=, # all_data/batch_num = 
         validation_data=test_dataset,
         validation_steps=)
    

提交回复
热议问题