NormLimitRegularizer

class NormLimitRegularizer(*, weight=1.0, apply_only_once=False, dim=-1, p=2.0, power_norm=True, max_norm=1.0, **kwargs)[source]

Bases: Regularizer

A regularizer which formulates a soft constraint on a maximum norm.

Initialize the regularizer.

Parameters
  • weight (float) – The relative weight of the regularization

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

  • dim (Optional[int]) – the dimension along which to calculate the Lp norm, cf. powersum_norm()

  • p (float) – the parameter \(p\) of the Lp norm, cf. powersum_norm()

  • power_norm (bool) – whether to use the \(p\) power of the norm instead

  • max_norm (float) – the maximum norm until which no penalty is added

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

Methods Summary

forward(x)

Compute the regularization term for one tensor.

Methods Documentation

forward(x)[source]

Compute the regularization term for one tensor.

Return type

FloatTensor

Parameters

x (FloatTensor) –