BoxEInteraction
- class BoxEInteraction(tanh_map=True, p=2, power_norm=False)[source]
Bases:
NormBasedInteraction
[Tuple
[FloatTensor
,FloatTensor
],Tuple
[FloatTensor
,FloatTensor
,FloatTensor
,FloatTensor
,FloatTensor
,FloatTensor
],Tuple
[FloatTensor
,FloatTensor
]]An implementation of the BoxE interaction from [abboud2020].
Instantiate the interaction module.
- Parameters
Attributes Summary
The symbolic shapes for entity representations
The symbolic shapes for relation representations
Methods Summary
func
(h_bump, rh_base, rh_delta, rh_size, ...)Evalute the BoxE interaction function from [abboud2020].
Attributes Documentation
- relation_shape: Sequence[str] = ('d', 'd', 's', 'd', 'd', 's')
The symbolic shapes for relation representations
Methods Documentation
- func(h_bump, rh_base, rh_delta, rh_size, rt_base, rt_delta, rt_size, t_pos, t_bump, tanh_map=True, p=2, power_norm=False)
Evalute the BoxE interaction function from [abboud2020].
Entities are described via position and bump. Relations are described as a pair of boxes, where each box is parametrized as triple (base, delta, size), where # TODO
Note
this interaction relies on Abboud’s point-to-box distance
pykeen.utils.point_to_box_distance()
.- Parameters
h_pos (
FloatTensor
) – shape: (*batch_dims, d) the head entity positionh_bump (
FloatTensor
) – shape: (*batch_dims, d) the head entity bumprh_base (
FloatTensor
) – shape: (*batch_dims, d) the relation-specific head box base positionrh_delta (
FloatTensor
) – shape: (*batch_dims, d) # the relation-specific head box base shape (normalized to have a volume of 1):rh_size (
FloatTensor
) – shape: (*batch_dims, 1) the relation-specific head box size (a scalar)rt_base (
FloatTensor
) – shape: (*batch_dims, d) the relation-specific tail box base positionrt_delta (
FloatTensor
) – shape: (*batch_dims, d) # the relation-specific tail box base shape (normalized to have a volume of 1):rt_size (
FloatTensor
) – shape: (*batch_dims, d) the relation-specific tail box sizet_pos (
FloatTensor
) – shape: (*batch_dims, d) the tail entity positiont_bump (
FloatTensor
) – shape: (*batch_dims, d) the tail entity bumptanh_map (
bool
) – whether to apply the tanh mappingp (
int
) – the order of the norm to applypower_norm (
bool
) – whether to use the p-th power of the p-norm instead
- Return type
FloatTensor
- Returns
shape: batch_dims The scores.