prfmodel.fitters.losses.CorrelationLoss¶
- class prfmodel.fitters.losses.CorrelationLoss(name=None, reduction='sum_over_batch_size', dtype=None)¶
Correlation loss.
Computes the negative Pearson correlation coefficient loss. This loss is agnostic to differences in baseline and amplitude between true values and predictions. This makes it particularly useful for
GridFitterwhere it is the default loss.Inherits all arguments from
keras.losses.Loss.Notes
Computes the loss by first subtracting the mean from true values and predictions and then computing their cosine similarity. Different from the usual definition of the Pearson correlation coefficient, the loss is zero when either
y_trueory_predare constant (instead ofNaN).Because the loss is invariant to baseline and amplitude, parameters that only shift or scale the prediction are not identifiable under it. See the notes of
GridFitterfor the consequences.- call(y_true: prfmodel.typing.Tensor, y_pred: prfmodel.typing.Tensor) prfmodel.typing.Tensor¶
Compute the loss.
- Parameters:
y_true (
prfmodel.typing.Tensor) – Tensor of true targets.y_pred (
prfmodel.typing.Tensor) – Tensor of predicted targets.
- Returns:
Correlation loss. Shape depends on the
reductionargument in the class constructor.- Return type: