rllib/utils/tf_utils.py
def explained_variance(y: TensorType, pred: TensorType) -> TensorType:
    """Computes the explained variance for a pair of labels and predictions.

    The formula used is:
    max(-1.0, 1.0 - (std(y - pred)^2 / std(y)^2))

    Args:
        y: The labels.
        pred: The predictions.

    Returns:
        The explained variance given a pair of labels and predictions.
    """
    _, y_var = tf.nn.moments(y, axes=[0])
    _, diff_var = tf.nn.moments(y - pred, axes=[0])
    return tf.maximum(-1.0, 1 - (diff_var / y_var))
Computes the explained variance for a pair of labels and predictions.

    The formula used is:
    max(-1.0, 1.0 - (std(y - pred)^2 / std(y)^2))

    Args:
        y: The labels.
        pred: The predictions.

    Returns:
        The explained variance given a pair of labels and predictions.
    
Computes the explained variance for a pair of labels and predictions.
Computes the explained variance for a pair of labels and predictions .
def explained_variance(y: TensorType, pred: TensorType) -> TensorType:
    _, y_var = tf.nn.moments(y, axes=[0])
    _, diff_var = tf.nn.moments(y - pred, axes=[0])
    return tf.maximum(-1.0, 1 - (diff_var / y_var))
def explained_variance ( y : TensorType , pred : TensorType ) -> TensorType : _ , y_var = tf . nn . moments ( y , axes = [ 0 ] ) _ , diff_var = tf . nn . moments ( y - pred , axes = [ 0 ] ) return tf . maximum ( - 1.0 , 1 - ( diff_var / y_var ) )
Computes the explained variance for a pair of labels and predictions.
Computes the explained variance for a pair of labels and predictions .
"""Computes the explained variance for a pair of labels and predictions.

    The formula used is:
    max(-1.0, 1.0 - (std(y - pred)^2 / std(y)^2))

    Args:
        y: The labels.
        pred: The predictions.

    Returns:
        The explained variance given a pair of labels and predictions.
    """
The explained variance given a pair of labels and predictions.
The explained variance given a pair of labels and predictions .
y
TensorType
None
pred
TensorType
None