CombinedCompGCNRepresentations

class CombinedCompGCNRepresentations(*, triples_factory: CoreTriplesFactory, entity_representations: str | Representation | type[Representation] | None = None, entity_representations_kwargs: Mapping[str, Any] | None = None, relation_representations: str | Representation | type[Representation] | None = None, relation_representations_kwargs: Mapping[str, Any] | None = None, num_layers: int | None = 1, dims: None | int | Sequence[int] = None, layer_kwargs: Mapping[str, Any] | None = None)[source]

Bases: Module

A sequence of CompGCN layers.

Initialize the combined entity and relation representation module.

Parameters:
  • triples_factory (CoreTriplesFactory) – The triples factory containing the training triples.

  • entity_representations (HintOrType[Representation]) – the base entity representations

  • entity_representations_kwargs (OptionalKwargs) – additional keyword parameters for the base entity representations

  • relation_representations (HintOrType[Representation]) – the base relation representations

  • relation_representations_kwargs (OptionalKwargs) – additional keyword parameters for the base relation representations

  • num_layers (int | None) – The number of message passing layers to use. If None, will be inferred by len(dims), i.e., requires dims to be a sequence / list.

  • dims (None | int | Sequence[int]) – The hidden dimensions to use. If None, defaults to the embedding dimension of the base representations. If an integer, is the same for all layers. The last dimension is equal to the output dimension.

  • layer_kwargs (Mapping[str, Any] | None) – Additional key-word based parameters passed to the individual layers; cf. CompGCNLayer.

Raises:

ValueError – for several invalid combinations of arguments: 1. If the dimensions were given as an integer but no number of layers were given 2. If the dimensions were given as a ist but it does not match the number of layers that were given

Methods Summary

forward()

Compute enriched representations.

post_parameter_update()

split()

Return the separated representations.

train([mode])

Set the module in training mode.

Methods Documentation

forward() tuple[Tensor, Tensor][source]

Compute enriched representations.

Return type:

tuple[Tensor, Tensor]

post_parameter_update() None[source]
Return type:

None

split() tuple[SingleCompGCNRepresentation, SingleCompGCNRepresentation][source]

Return the separated representations.

Return type:

tuple[SingleCompGCNRepresentation, SingleCompGCNRepresentation]

train(mode: bool = True)[source]

Set the module in training mode.

This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g. Dropout, BatchNorm, etc.

Args:
mode (bool): whether to set training mode (True) or evaluation

mode (False). Default: True.

Returns:

Module: self

Parameters:

mode (bool)