TransH
- class TransH(*, embedding_dim: int = 50, scoring_fct_norm: int = 2, power_norm: bool = False, entity_initializer: str | ~collections.abc.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_normal_>, regularizer: str | ~pykeen.regularizers.Regularizer | type[~pykeen.regularizers.Regularizer] | None = None, regularizer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, relation_initializer: str | ~collections.abc.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_normal_>, relation_regularizer: str | ~pykeen.regularizers.Regularizer | type[~pykeen.regularizers.Regularizer] | None = None, relation_regularizer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, **kwargs)[source]
Bases:
ERModel
[Tensor
,tuple
[Tensor
,Tensor
],Tensor
]An implementation of TransH [wang2014].
This model represents entities as \(d\)-dimensional vectors, and relations as pair of a normal vector and translation inside the hyperplane. They are stored in an
Embedding
. The representations are then passed to theTransHInteraction
function to obtain scores.See also
OpenKE implementation of TransH
Initialize TransH.
- Parameters:
embedding_dim (int) – the entity embedding dimension \(d\). Is usually \(d \in [50, 300]\).
scoring_fct_norm (int) – The norm used with
torch.linalg.vector_norm()
. Typically is 1 or 2.power_norm (bool) – Whether to use the p-th power of the \(L_p\) norm. It has the advantage of being differentiable around 0, and numerically more stable.
entity_initializer (str | Callable[[Tensor], Tensor] | None) – The entity initializer function. Defaults to
pykeen.nn.init.xavier_normal_()
.regularizer (str | Regularizer | type[Regularizer] | None) – The entity regularizer. Defaults to
pykeen.models.TransH.regularizer_default
.regularizer_kwargs (Mapping[str, Any] | None) – Keyword-based parameters for the entity regularizer. If entity_regularizer is None, the default from
pykeen.models.TransH.regularizer_default_kwargs
will be used insteadrelation_initializer (str | Callable[[Tensor], Tensor] | None) – The relation initializer function. Defaults to
pykeen.nn.init.xavier_normal_()
.relation_regularizer (str | Regularizer | type[Regularizer] | None) – The relation regularizer. Defaults to
pykeen.models.TransH.relation_regularizer_default
.relation_regularizer_kwargs (Mapping[str, Any] | None) – Keyword-based parameters for the relation regularizer. If relation_regularizer is None, the default from
pykeen.models.TransH.relation_regularizer_default_kwargs
will be used insteadkwargs – Remaining keyword arguments are passed to
ERModel
Attributes Summary
The default strategy for optimizing the model's hyper-parameters
The default parameters for the default regularizer class
The settings used by [wang2014] for TransH
Attributes Documentation
- hpo_default: ClassVar[Mapping[str, Any]] = {'embedding_dim': {'high': 256, 'low': 16, 'q': 16, 'type': <class 'int'>}, 'scoring_fct_norm': {'high': 2, 'low': 1, 'type': <class 'int'>}}
The default strategy for optimizing the model’s hyper-parameters