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
  • tanh_map (bool) – Should the hyperbolic tangent be applied to all representations prior to model scoring?

  • p (int) – the order of the norm

  • power_norm (bool) – whether to use the p-th power of the norm instead

Attributes Summary

entity_shape

The symbolic shapes for entity representations

relation_shape

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

entity_shape: Sequence[str] = ('d', 'd')

The symbolic shapes for entity representations

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 position

  • h_bump (FloatTensor) – shape: (*batch_dims, d) the head entity bump

  • rh_base (FloatTensor) – shape: (*batch_dims, d) the relation-specific head box base position

  • rh_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 position

  • rt_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 size

  • t_pos (FloatTensor) – shape: (*batch_dims, d) the tail entity position

  • t_bump (FloatTensor) – shape: (*batch_dims, d) the tail entity bump

  • tanh_map (bool) – whether to apply the tanh mapping

  • p (int) – the order of the norm to apply

  • power_norm (bool) – whether to use the p-th power of the p-norm instead

Return type

FloatTensor

Returns

shape: batch_dims The scores.