vp_suite.measure.loss_provider

class PredictionLossProvider(config)

Bases: object

This class provides bundled access to multiple losses. With this class’s get_losses() method, all specified loss values are calculated on the same input prediction and target tensor.

device

A string specifying whether to use the GPU for calculations (cuda) or the CPU (cpu).

Type

str

losses

The concrete instantiated losses that the loss provider uses when provided with input tensors.

Type

dict

__init__(config)

Initializes the provider by extracting device and loss IDs from the provided config dict and instantiating the losses that shall be used.

Parameters

config (dict) – A dictionary containing the devices and losses to use. The provided losses come with the scales that should be multiplied by the respective loss value.

get_losses(pred, target)

Takes in tensors of predicted frames and the corresponding ground truth and calculates the losses for the loss classes instantiated previously. Each loss

Parameters
  • pred (torch.Tensor) – The predicted frame sequence as a 5D float tensor (batch, frames, c, h, w).

  • target (torch.Tensor) – The ground truth frame sequence as a 5D float tensor (batch, frames, c, h, w)

Returns

  1. A dictionary containing the loss IDs and the corresponding values of each loss in display representation.

  2. The sum of scaled losses (total loss).