OrthogonalityRegularizer

class OrthogonalityRegularizer(*, weight: float = 1.0, apply_only_once: bool = True, epsilon: float = 1e-05, **kwargs)[source]

Bases: Regularizer

A regularizer for the soft orthogonality constraints from [wang2014].

Initialize the regularizer.

Parameters:
  • weight (Tensor) – The relative weight of the regularization

  • apply_only_once (bool) – Should the regularization be applied more than once after reset?

  • epsilon (float) – a small value used to check for approximate orthogonality

  • kwargs – additional keyword-based parameters passed to Regularizer.__init__()

Methods Summary

forward(x)

Compute the regularization term for one tensor.

update(*tensors)

Update the regularization term based on passed tensors.

Methods Documentation

forward(x: Tensor) Tensor[source]

Compute the regularization term for one tensor.

Parameters:

x (Tensor)

Return type:

Tensor

update(*tensors: Tensor) None[source]

Update the regularization term based on passed tensors.

Parameters:

tensors (Tensor)

Return type:

None