Regularizers

Regularization in PyKEEN.

Functions

get_regularizer_cls(query)

Get the regularizer class.

Classes

LpRegularizer([weight, dim, normalize, p, …])

A simple L_p norm based regularizer.

NoRegularizer([weight, apply_only_once, …])

A regularizer which does not perform any regularization.

CombinedRegularizer(regularizers[, …])

A convex combination of regularizers.

PowerSumRegularizer([weight, dim, …])

A simple x^p based regularizer.

TransHRegularizer([weight, epsilon, parameters])

A regularizer for the soft constraints in TransH.

Class Inheritance Diagram

Inheritance diagram of pykeen.regularizers.LpRegularizer, pykeen.regularizers.NoRegularizer, pykeen.regularizers.CombinedRegularizer, pykeen.regularizers.PowerSumRegularizer, pykeen.regularizers.TransHRegularizer

Base Classes

class Regularizer(weight=1.0, apply_only_once=False, parameters=None)[source]

A base class for all regularizers.

Instantiate 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?

  • parameters (Optional[Iterable[Parameter]]) – Specific parameters to track. if none given, it’s expected that your model automatically delegates to the update() function.

add_parameter(parameter)[source]

Add a parameter for regularization.

Return type

None

apply_only_once: bool

Should the regularization only be applied once? This was used for ConvKB and defaults to False.

abstract forward(x)[source]

Compute the regularization term for one tensor.

Return type

FloatTensor

classmethod get_normalized_name()[source]

Get the normalized name of the regularizer class.

Return type

str

hpo_default: ClassVar[Mapping[str, Any]]

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

pop_regularization_term()[source]

Return the weighted regularization term, and reset the regularize afterwards.

Return type

FloatTensor

regularization_term: torch.FloatTensor

The current regularization term (a scalar)

reset()[source]

Reset the regularization term to zero.

Return type

None

property term

Return the weighted regularization term.

Return type

FloatTensor

update(*tensors)[source]

Update the regularization term based on passed tensors.

Return type

None

updated: bool

Has this regularizer been updated since last being reset?

weight: torch.FloatTensor

The overall regularization weight