dacapo.experiments.tasks.losses.affinities_loss
Classes
A class representing a loss function that calculates the loss between affinities and local shape descriptors (LSDs). |
Module Contents
- class dacapo.experiments.tasks.losses.affinities_loss.AffinitiesLoss(num_affinities: int, lsds_to_affs_weight_ratio: float)
A class representing a loss function that calculates the loss between affinities and local shape descriptors (LSDs).
- num_affinities
int the number of affinities
- lsds_to_affs_weight_ratio
float the ratio of the weight of the loss between affinities and LSDs
- compute(prediction, target, weight=None)
Calculate the total loss between prediction and target.
Note
The AffinitiesLoss class is used to calculate the loss between affinities and local shape descriptors (LSDs).
- num_affinities
- lsds_to_affs_weight_ratio
- compute(prediction, target, weight)
Method to calculate the total loss between affinities and LSDs.
- Parameters:
prediction – torch.Tensor the model’s prediction
target – torch.Tensor the target values
weight – torch.Tensor the weight to apply to the loss
- Returns:
- torch.Tensor
the total loss between affinities and LSDs
- Raises:
ValueError – if the number of affinities in the prediction and target does not match
Examples
>>> affinities_loss = AffinitiesLoss(3, 0.5) >>> prediction = torch.tensor([[1, 2, 3, 4], [5, 6, 7, 8]]) >>> target = torch.tensor([[9, 10, 11, 12], [13, 14, 15, 16]]) >>> weight = torch.tensor([[1, 1, 1, 1], [1, 1, 1, 1]]) >>> affinities_loss.compute(prediction, target, weight) tensor(0.5)
Note
The AffinitiesLoss class is used to calculate the loss between affinities and local shape descriptors (LSDs).