composer.models.loss#
composer.models.loss
Functions
Checks if a given set of targets are indices by looking at the type. |
|
|
composer.models.loss.ensure_targets_one_hot |
Drop-in replacement for |
|
|
Converts a tensor of probabilities to a dense label tensor. |
Classes
Torchmetric cross entropy loss implementation. |
|
The Dice Coefficient for evaluating image segmentation. |
|
Torchmetric mean Intersection-over-Union (mIoU) implementation. |
|
Base class for all metrics present in the Metrics API. |
|
|
composer.models.loss.torch.Tensor |
Attributes
Optional
TYPE_CHECKING
Tuple
annotations
- class composer.models.loss.CrossEntropyLoss(ignore_index=- 100, dist_sync_on_step=False)[source]#
Bases:
torchmetrics.metric.Metric
Torchmetric cross entropy loss implementation.
This class implements cross entropy loss as a torchmetric so that it can be returned by the
metric()
function inComposerModel
.
- class composer.models.loss.Dice(nclass)[source]#
Bases:
torchmetrics.metric.Metric
The Dice Coefficient for evaluating image segmentation.
The Dice Coefficient measures how similar predictions and targets are. More concretely, it is computed as 2 * the Area of Overlap divided by the total number of pixels in both images.
- class composer.models.loss.MIoU(num_classes, ignore_index=- 1)[source]#
Bases:
torchmetrics.metric.Metric
Torchmetric mean Intersection-over-Union (mIoU) implementation.
IoU calculates the intersection area between the predicted class mask and the label class mask. The intersection is then divided by the area of the union of the predicted and label masks. This measures the quality of predicted class mask with respect to the label. The IoU for each class is then averaged and the final result is the mIoU score. Implementation is primarily based on mmsegmentation: https://github.com/open-mmlab/mmsegmentation/blob/master/mmseg/core/evaluation/metrics.py#L132
- Parameters
- composer.models.loss.check_for_index_targets(targets)[source]#
Checks if a given set of targets are indices by looking at the type.
- composer.models.loss.soft_cross_entropy(input, target, weight=None, size_average=None, ignore_index=- 100, reduce=None, reduction='mean')[source]#
Drop-in replacement for
torch.CrossEntropy
that can handle dense labels.This function will be obsolete with this update.