extorch.nn.modules.loss

CrossEntropyLabelSmooth

CrossEntropyMixupLoss

CrossEntropyLoss with mixup technique.

DECLoss

Loss used by Deep Embedded Clustering (DEC, `Link`_).

class extorch.nn.modules.loss.CrossEntropyLabelSmooth(epsilon: float)[source]

Bases: torch.nn.modules.module.Module

forward(input: torch.Tensor, target: torch.Tensor) torch.Tensor[source]

Defines 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.

training: bool
class extorch.nn.modules.loss.CrossEntropyMixupLoss(alpha: float, **kwargs)[source]

Bases: torch.nn.modules.module.Module

CrossEntropyLoss with mixup technique.

Parameters
  • alpha (float) – Parameter of the beta distribution. Default: 1.0.

  • kwargs – Other arguments of torch.nn.CrossEntropyLoss (`Link`_).

forward(input: torch.Tensor, target: torch.Tensor) torch.Tensor[source]

Defines 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.

training: bool
class extorch.nn.modules.loss.DECLoss(alpha: float = 1.0, **kwargs)[source]

Bases: torch.nn.modules.module.Module

Loss used by Deep Embedded Clustering (DEC, `Link`_).

Parameters

alpha (float) – The degrees of freedom of the Student’s tdistribution. Default: 1.0.

Examples::
>>> criterion = DECLoss(alpha = 1.)
>>> embeddings = torch.randn((2, 10))
>>> centers = torch.randn((3, 10))
>>> loss = criterion(embeddings, centers)
forward(input: torch.Tensor, centers: torch.Tensor) torch.Tensor[source]

Defines 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.

static target_distribution(input: torch.Tensor) torch.Tensor[source]
training: bool