pytorch-forecasting icon indicating copy to clipboard operation
pytorch-forecasting copied to clipboard

Combined loss function using multiple targets

Open serhan-gul opened this issue 2 years ago • 0 comments

  • PyTorch-Forecasting version: 0.10.2
  • PyTorch version: 1.11.0
  • Python version: 3.10.5
  • Operating System: macOS 12.4

I have a multi-target regression problem where I currently use MAE loss for each of the targets.

model = LitFCMultiTargetModel.from_dataset(
            train_dataset,
            hidden_size=self.hidden_size,
            n_hidden_layers=self.n_hidden_layers,
            log_interval=1,
            loss=MultiLoss(metrics=[MAE()] * len(self.targets)),
)

However, the targets are related to each other geometrically, i.e. they are x, y, z coordinates measured from a sensor. Therefore, I want to use the Euclidean distance between the predicted and target values as loss function instead of measuring the loss for each coordinate separately using MAE. Is there a way to create such a combined loss function?

serhan-gul avatar Aug 11 '22 14:08 serhan-gul