A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.kge.DistMult.html below:

torch_geometric.nn.kge.DistMult — pytorch_geometric documentation

pytorch_geometric torch_geometric.nn.kge.DistMult
class DistMult(num_nodes: int, num_relations: int, hidden_channels: int, margin: float = 1.0, sparse: bool = False)[source]

Bases: KGEModel

The DistMult model from the “Embedding Entities and Relations for Learning and Inference in Knowledge Bases” paper.

DistMult models relations as diagonal matrices, which simplifies the bi-linear interaction between the head and tail entities to the score function:

\[d(h, r, t) = < \mathbf{e}_h, \mathbf{e}_r, \mathbf{e}_t >\]

Parameters:
  • num_nodes (int) – The number of nodes/entities in the graph.

  • num_relations (int) – The number of relations in the graph.

  • hidden_channels (int) – The hidden embedding size.

  • margin (float, optional) – The margin of the ranking loss. (default: 1.0)

  • sparse (bool, optional) – If set to True, gradients w.r.t. to the embedding matrices will be sparse. (default: False)

reset_parameters()[source]

Resets all learnable parameters of the module.

forward(head_index: Tensor, rel_type: Tensor, tail_index: Tensor) Tensor[source]

Returns the score for the given triplet.

Parameters:
Return type:

Tensor

loss(head_index: Tensor, rel_type: Tensor, tail_index: Tensor) Tensor[source]

Returns the loss value for the given triplet.

Parameters:
Return type:

Tensor


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4