CombinedCompGCNRepresentations

class CombinedCompGCNRepresentations(*, triples_factory, entity_representations=None, entity_representations_kwargs=None, relation_representations=None, relation_representations_kwargs=None, num_layers=1, dims=None, layer_kwargs=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 (Union[str, Representation, Type[Representation], None]) – the base entity representations

  • entity_representations_kwargs (Optional[Mapping[str, Any]]) – additional keyword parameters for the base entity representations

  • relation_representations (Union[str, Representation, Type[Representation], None]) – the base relation representations

  • relation_representations_kwargs (Optional[Mapping[str, Any]]) – additional keyword parameters for the base relation representations

  • num_layers (Optional[int]) – 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 (Union[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 (Optional[Mapping[str, Any]]) – 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()

rtype:

None

split()

Return the separated representations.

train([mode])

Set the module in training mode.

Methods Documentation

forward()[source]

Compute enriched representations.

Return type:

Tuple[FloatTensor, FloatTensor]

post_parameter_update()[source]
Return type:

None

split()[source]

Return the separated representations.

Return type:

Tuple[SingleCompGCNRepresentation, SingleCompGCNRepresentation]

train(mode=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) –