LpRegularizer

class LpRegularizer(*, weight=1.0, apply_only_once=False, dim=-1, normalize=False, p=2.0, **kwargs)[source]

Bases: Regularizer

A simple L_p norm based regularizer.

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. lp_norm()

  • normalize (bool) – whether to normalize the norm by the dimension, cf. lp_norm()

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

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

Attributes Summary

hpo_default

The default strategy for optimizing the LP regularizer's hyper-parameters

Methods Summary

forward(x)

Compute the regularization term for one tensor.

Attributes Documentation

hpo_default: ClassVar[Mapping[str, Any]] = {'weight': {'high': 1.0, 'low': 0.01, 'scale': 'log', 'type': <class 'float'>}}

The default strategy for optimizing the LP regularizer’s hyper-parameters

Methods Documentation

forward(x)[source]

Compute the regularization term for one tensor.

Return type

FloatTensor

Parameters

x (FloatTensor) –