SimplEInteraction

class SimplEInteraction(clamp_score: None | float | tuple[float, float] = None)[source]

Bases: FunctionalInteraction[tuple[Tensor, Tensor], tuple[Tensor, Tensor], tuple[Tensor, Tensor]]

A module wrapper for the SimplE interaction function.

Initialize the interaction module.

Parameters:

clamp_score (None | float | tuple[float, float]) – whether to clamp scores into a fixed interval

Attributes Summary

entity_shape

The symbolic shapes for entity representations

relation_shape

The symbolic shapes for relation representations

Methods Summary

func(r, t, h_inv, r_inv, t_inv[, clamp])

Evaluate the SimplE interaction function.

Attributes Documentation

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

The symbolic shapes for entity representations

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

The symbolic shapes for relation representations

Methods Documentation

func(r: Tensor, t: Tensor, h_inv: Tensor, r_inv: Tensor, t_inv: Tensor, clamp: tuple[float, float] | None = None) Tensor

Evaluate the SimplE interaction function.

Parameters:
  • h (Tensor) – shape: (*batch_dims, dim) The head representations.

  • r (Tensor) – shape: (*batch_dims, dim, dim) The relation representations.

  • t (Tensor) – shape: (*batch_dims, dim) The tail representations.

  • h_inv (Tensor) – shape: (*batch_dims, dim) The inverse head representations.

  • r_inv (Tensor) – shape: (*batch_dims, dim, dim) The relation representations.

  • t_inv (Tensor) – shape: (*batch_dims, dim) The tail representations.

  • clamp (tuple[float, float] | None) – Clamp the scores to the given range.

Returns:

shape: batch_dims The scores.

Return type:

Tensor