Skip to content

deeplabcut.pose_estimation_pytorch.models.criterions.base

Classes:

Name Description
BaseCriterion
BaseLossAggregator

BaseCriterion

Bases: ABC, Module

Methods:

Name Description
forward

Args:

Source code in deeplabcut/pose_estimation_pytorch/models/criterions/base.py
class BaseCriterion(ABC, nn.Module):
    def __init__(self) -> None:
        super().__init__()

    @abstractmethod
    def forward(self, output: torch.Tensor, target: torch.Tensor, **kwargs) -> torch.Tensor:
        """
        Args:
            output: the output from which to compute the loss
            target: the target for the loss

        Returns:
            the different losses for the module, including one "total_loss" key which
            is the loss from which to start backpropagation
        """
        raise NotImplementedError

forward abstractmethod

forward(output: Tensor, target: Tensor, **kwargs) -> torch.Tensor

Parameters:

Name Type Description Default

output

Tensor

the output from which to compute the loss

required

target

Tensor

the target for the loss

required

Returns:

Type Description
Tensor

the different losses for the module, including one "total_loss" key which is the loss from which to start backpropagation

Source code in deeplabcut/pose_estimation_pytorch/models/criterions/base.py
@abstractmethod
def forward(self, output: torch.Tensor, target: torch.Tensor, **kwargs) -> torch.Tensor:
    """
    Args:
        output: the output from which to compute the loss
        target: the target for the loss

    Returns:
        the different losses for the module, including one "total_loss" key which
        is the loss from which to start backpropagation
    """
    raise NotImplementedError

BaseLossAggregator

Bases: ABC, Module

Methods:

Name Description
forward

Args:

Source code in deeplabcut/pose_estimation_pytorch/models/criterions/base.py
class BaseLossAggregator(ABC, nn.Module):
    @abstractmethod
    def forward(self, losses: dict[str, torch.Tensor]) -> torch.Tensor:
        """
        Args:
            losses: the losses to aggregate

        Returns:
            the aggregate loss
        """
        raise NotImplementedError

forward abstractmethod

forward(losses: dict[str, Tensor]) -> torch.Tensor

Parameters:

Name Type Description Default

losses

dict[str, Tensor]

the losses to aggregate

required

Returns:

Type Description
Tensor

the aggregate loss

Source code in deeplabcut/pose_estimation_pytorch/models/criterions/base.py
@abstractmethod
def forward(self, losses: dict[str, torch.Tensor]) -> torch.Tensor:
    """
    Args:
        losses: the losses to aggregate

    Returns:
        the aggregate loss
    """
    raise NotImplementedError