mindflow.loss.MTLWeightedLoss

class mindflow.loss.MTLWeightedLoss(num_losses, bound_param=0.0)[source]

Compute the MTL strategy weighted multi-task losses automatically. For more information, please refer to MTL weighted losses .

Parameters
  • num_losses (int) – The number of multi-task losses, should be positive integer.

  • bound_param (float) – The square addition to weight and regularization when the mere bound is higher than certain constant given.

Inputs:
  • input - tuple of Tensors.

Outputs:

Tensor. losses for MTL weighted strategy.

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> from mindflow.loss import MTLWeightedLoss
>>> import mindspore
>>> from mindspore import Tensor
>>> net = MTLWeightedLoss(num_losses=2)
>>> input1 = Tensor(1.0, mindspore.float32)
>>> input2 = Tensor(0.8, mindspore.float32)
>>> output = net((input1, input2))
>>> print(output)
2.2862945