PowerSumRegularizer
- class PowerSumRegularizer(*, weight=1.0, apply_only_once=False, dim=-1, normalize=False, p=2.0, **kwargs)[source]
Bases:
Regularizer
A simple x^p based regularizer.
Has some nice properties, cf. e.g. https://github.com/pytorch/pytorch/issues/28119.
Initialize the regularizer.
- Parameters:
weight (
float
) – The relative weight of the regularizationapply_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()
normalize (
bool
) – whether to normalize the norm by the dimension, cf.powersum_norm()
p (
float
) – the parameter \(p\) of the Lp norm, cf.powersum_norm()
kwargs – additional keyword-based parameters passed to
Regularizer.__init__()
Methods Summary
forward
(x)Compute the regularization term for one tensor.
Methods Documentation