Losses

Loss

Base class for all losses.

MSELoss

Mean squared error loss.

CrossEntropyLoss

Cross-entropy loss.

MallowDistanceLoss

Mallow distance loss.

class Loss[source]

Base class for losses. All losses should support an optional weights argument.

abstract forward(input, target, weights=None)[source]

Abstract method for computing the loss.

Return type:

Tensor

class MSELoss[source]
forward(input, target, weights=None)[source]

Compute mean squared error loss.

Parameters:
  • input (Tensor) – The input tensor.

  • target (Tensor) – The target tensor.

  • weights (Tensor, optional) – The weights tensor.

Return type:

Tensor

class CrossEntropyLoss[source]
forward(input, target, weights=None)[source]

Compute cross-entropy loss.

Parameters:
  • input (Tensor) – The input tensor.

  • target (Tensor) – The target tensor.

  • weights (Tensor, optional) – The weights tensor.

Return type:

Tensor

class MallowDistanceLoss[source]
forward(input, target, weights)[source]

Compute Mallow distance loss.

Parameters:
  • input (Tensor) – The input tensor.

  • target (Tensor) – The target tensor.

  • weights (Tensor) – The weights tensor.

Return type:

Tensor