credit.losses.xtanh#

Classes#

XTanhLoss

X-Tanh Loss Function.

Module Contents#

class credit.losses.xtanh.XTanhLoss(reduction='mean')#

Bases: torch.nn.Module

X-Tanh Loss Function.

This loss function computes the element-wise product of the prediction error and the hyperbolic tangent of the error. This loss function aims to be more robust to outliers than traditional MSE.

Parameters:

reduction (str) – Specifies the reduction to apply to the output: ‘mean’ | ‘none’. ‘mean’: the output is averaged; ‘none’: no reduction is applied.

reduction = 'mean'#
forward(y_t, y_prime_t)#

Forward pass for X-Tanh loss.

Parameters:
  • y_t (torch.Tensor) – Target tensor.

  • y_prime_t (torch.Tensor) – Predicted tensor.

Returns:

X-Tanh loss value.

Return type:

torch.Tensor