add_custom_metric

The purpose of the leap_binder.add_custom_metric function is to add a custom metric suited to your needs to the tensorleap platform.

code_loader.leap_binder.add_custom_metric(
    function=Callable[..., tf.Tensor],
    name=str
)
Args

function

A function that returns the required metrics

name

The name of the the metric

Examples

Basic Usage

import tensorflow as tf

def custom_metric_mean_distance(y_true, y_pred):
    rank = len(y_true.shape)
    axis = range(1, rank)
    diff = y_true - y_pred
    return tf.reduce_mean(diff, axis=axis)

leap_binder.add_custom_metric(custom_metric_mean_distance, "mean distance")

Full script usage can be found at Integration Script.

Last updated