jactorch.nn.losses#

Classes

Class AverageLoss

class AverageLoss[source]#

Bases: Module

__init__(average='valid')[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Class BinaryCrossEntropyLossWithProbs

class BinaryCrossEntropyLossWithProbs[source]#

Bases: AverageLoss

__init__(average='valid')#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(logits, target, mask=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Class CompatibleCrossEntropyLossWithProbs

class CompatibleCrossEntropyLossWithProbs[source]#

Bases: CrossEntropyLossWithProbs

__init__(dim=-1, weight=None, ignore_index=None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(probs, target, mask=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Class CompatibleMSEProbabilityLoss

class CompatibleMSEProbabilityLoss[source]#

Bases: Module

__init__(weight=None, ignore_index=None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(probs, target)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Class CosineLoss

class CosineLoss[source]#

Bases: AverageLoss

__init__(average='valid')#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(output, target, mask=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Class CrossEntropyLoss

CrossEntropyLoss#

alias of CrossEntropyLossWithLogits

Class CrossEntropyLossWithLogits

class CrossEntropyLossWithLogits[source]#

Bases: AverageLoss

__init__(dim=-1, average='valid')[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(logits, target, mask=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Class CrossEntropyLossWithProbs

class CrossEntropyLossWithProbs[source]#

Bases: AverageLoss

__init__(dim=-1, average='valid')[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(probs, target, mask=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Class LossAverageMethod

class LossAverageMethod[source]#

Bases: JacEnum

__new__(value)#
classmethod assert_valid(value)#

Assert if the value is a valid choice.

classmethod choice_names()#

Returns the list of the name of all possible choices.

classmethod choice_objs()#

Returns the list of the object of all possible choices.

classmethod choice_values()#

Returns the list of the value of all possible choices.

classmethod from_string(value)#
Parameters:

value (str | JacEnum)

Return type:

JacEnum

classmethod is_valid(value)#

Check if the value is a valid choice.

classmethod type_name()#

Return the type name of the enum.

ALL = 'all'#
NONE = 'none'#
VALID = 'valid'#

Class MSELoss

class MSELoss[source]#

Bases: AverageLoss

__init__(average='valid')[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(output, target, mask=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Class PNBalancedBinaryCrossEntropyLossWithProbs

class PNBalancedBinaryCrossEntropyLossWithProbs[source]#

Bases: Module

forward(probs, target, mask=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Class SmoothL1Loss

class SmoothL1Loss[source]#

Bases: AverageLoss

__init__(sigma=3.0, average='valid')[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(output, target, sidechain=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.