Creates a new tf.estimator.Estimator
which has given metrics.
tf.contrib.estimator.add_metrics(
estimator, metric_fn
)
Example:
def my_auc(labels, predictions):
return {'auc': tf.metrics.auc(labels, predictions['logistic'])}
estimator = tf.estimator.DNNClassifier(...)
estimator = tf.contrib.estimator.add_metrics(estimator, my_auc)
estimator.train(...)
estimator.evaluate(...)
Example usage of custom metric which uses features:
def my_auc(features, labels, predictions):
return {'auc': tf.metrics.auc(
labels, predictions['logistic'], weights=features['weight'])}
estimator = tf.estimator.DNNClassifier(...)
estimator = tf.contrib.estimator.add_metrics(estimator, my_auc)
estimator.train(...)
estimator.evaluate(...)
Args | |
---|---|
estimator
|
A tf.estimator.Estimator object.
|
metric_fn
|
A function which should obey the following signature:
|
Returns | |
---|---|
A new tf.estimator.Estimator which has a union of original metrics with
given ones.
|