helios.losses.utils =================== .. py:module:: helios.losses.utils Attributes ---------- .. autoapisummary:: helios.losses.utils.LOSS_REGISTRY Functions --------- .. autoapisummary:: helios.losses.utils.create_loss Module Contents --------------- .. py:data:: LOSS_REGISTRY Global instance of the registry for loss functions. By default, the registry contains the following losses: .. list-table:: Optimizers :header-rows: 1 * - Loss - Name * - ``torch.nn.L1Loss`` - L1Loss * - ``torch.nn.MSELoss`` - MSELoss * - ``torch.nn.CrossEntropyLoss`` - CrossEntropyLoss * - ``torch.nn.CTCLoss`` - CTCLoss * - ``torch.nn.NLLLoss`` - NLLLoss * - ``torch.nn.PoissonNLLLoss`` - PoissonNLLLoss * - ``torch.nn.GaussianNLLLoss`` - GaussianNLLLoss * - ``torch.nn.KLDivLoss`` - KLDivLoss * - ``torch.nn.BCELoss`` - BCELoss * - ``torch.nn.BCEWithLogitsLoss`` - BCEWithLogitsLoss * - ``torch.nn.MarginRankingLoss`` - MarginRankingLoss * - ``torch.nn.HingeEmbeddingLoss`` - HingeEmbeddingLoss * - ``torch.nn.MultiLabelMarginLoss`` - MultiLabelMarginLoss * - ``torch.nn.HuberLoss`` - HuberLoss * - ``torch.nn.SmoothL1Loss`` - SmoothL1Loss * - ``torch.nn.SoftMarginLoss`` - SoftMarginLoss * - ``torch.nn.MultiLabelMarginLoss`` - MultiLabelMarginLoss * - ``torch.nn.CosineEmbeddingLoss`` - CosineEmbeddingLoss * - ``torch.nn.MultiMarginLoss`` - MultiMarginLoss * - ``torch.nn.TripletMarginLoss`` - TripletMarginLoss * - ``torch.nn.TripletMarginWithDistanceLoss`` - TripletMarginWithDistanceLoss .. rubric:: Example .. code-block:: python import helios.losses as hll # This automatically registers your loss function. @hll.LOSS_REGISTRY.register class MyLoss: ... # Alternatively you can manually register a loss function like this: hll.LOSS_REGISTRY.register(MyLoss) .. py:function:: create_loss(type_name: str, *args: Any, **kwargs: Any) -> torch.nn.Module Create the loss function for the given type. :param type_name: the type of the loss to create. :param args: positional arguments to pass into the loss. :param kwargs: keyword arguments to pass into the loss. :returns: The loss function.