I've defined a custom keras model using Model subclass
. And I want to convert this model to estimator for distributed training. Simple codes are as follow:
tf.logging.set_verbosity(tf.logging.INFO)
model = EstimatorModel()
model.compile(optimizer=tf.keras.optimizers.Adam(),
loss='categorical_crossentropy',
metrics=['accuracy'])
estimator_model = tf.keras.estimator.model_to_estimator(
keras_model=model, model_dir=FLAGS.model_path)
estimator_model.train(input_fn=input_fn)
Code can run normally. Now, the question is the estimator only print the loss
, and didn't print the metric
. I've tried to add metric to estimator_model
using tf.estimator.add_metrics(estimator_model, my_auc)
, but it still not work. What should I do to solve this?