vis4d.op.loss.reducer

Definitions of loss reducers.

Loss reducers are usually used as the last step in loss computation to average or sum the loss maps from dense predictions or object detections.

Functions

identity_loss(loss)

Make no change to the loss.

mean_loss(loss)

Average the loss tensor values to a single value.

sum_loss(loss)

Sum the loss tensor values to a single value.

Classes

SumWeightedLoss(weight, avg_factor)

A loss reducer to calculated weighted sum loss.

class SumWeightedLoss(weight, avg_factor)[source]

A loss reducer to calculated weighted sum loss.

Initialize the loss reducer.

Parameters:
  • weight (float | Tensor) – Weights for each loss elements

  • avg_factor (float | Tensor) – average factor for the weighted loss

__call__(loss)[source]

Weight the loss elements and take the sum with the average factor.

Parameters:

loss (Tensor) – input loss

Returns:

output loss

Return type:

Tensor

identity_loss(loss)[source]

Make no change to the loss.

Return type:

Tensor

mean_loss(loss)[source]

Average the loss tensor values to a single value.

Parameters:

loss (Tensor) – Input multi-dimentional tensor.

Returns:

Tensor containing a single loss value.

Return type:

Tensor

sum_loss(loss)[source]

Sum the loss tensor values to a single value.

Parameters:

loss (Tensor) – Input multi-dimentional tensor.

Returns:

Tensor containing a single loss value.

Return type:

Tensor