mindelec.architecture.MTLWeightedLossCell

class mindelec.architecture.MTLWeightedLossCell(num_losses)[source]

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.

Inputs:
  • input - tuple of Tensors.

Outputs:

Scalar.

Supported Platforms:

Ascend

Examples

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