RGCN

class RGCN(*, triples_factory, embedding_dim=500, num_layers=2, base_entity_initializer=<function xavier_uniform_>, base_entity_initializer_kwargs=None, relation_initializer=<function xavier_uniform_>, relation_initializer_kwargs=None, relation_representations=None, interaction='DistMult', interaction_kwargs=None, use_bias=True, use_batch_norm=False, activation=None, activation_kwargs=None, edge_dropout=0.4, self_loop_dropout=0.2, edge_weighting=None, decomposition=None, decomposition_kwargs=None, **kwargs)[source]

Bases: pykeen.models.nbase.ERModel[torch.FloatTensor, pykeen.typing.RelationRepresentation, torch.FloatTensor]

An implementation of R-GCN from [schlichtkrull2018].

This model uses graph convolutions with relation-specific weights.

Initialize the module.

Parameters
  • triples_factory (CoreTriplesFactory) – The triples factory facilitates access to the dataset.

  • interaction (Union[str, Interaction[FloatTensor, ~RelationRepresentation, FloatTensor], Type[Interaction[FloatTensor, ~RelationRepresentation, FloatTensor]], None]) – The interaction module (e.g., TransE)

  • interaction_kwargs (Optional[Mapping[str, Any]]) – Additional key-word based parameters given to the interaction module’s constructor, if not already instantiated.

  • entity_representations – The entity representation or sequence of representations

  • relation_representations (Union[None, EmbeddingSpecification, RepresentationModule, Sequence[Union[EmbeddingSpecification, RepresentationModule]]]) – The relation representation or sequence of representations

  • loss – The loss to use. If None is given, use the loss default specific to the model subclass.

  • predict_with_sigmoid – Whether to apply sigmoid onto the scores when predicting scores. Applying sigmoid at prediction time may lead to exactly equal scores for certain triples with very high, or very low score. When not trained with applying sigmoid (or using BCEWithLogitsLoss), the scores are not calibrated to perform well with sigmoid.

  • preferred_device – The preferred device for model training and inference.

  • random_seed – A random seed to use for initialising the model’s weights. Should be set when aiming at reproducibility.

Attributes Summary

hpo_default

The default strategy for optimizing the model”s hyper-parameters

Attributes Documentation

hpo_default: ClassVar[Mapping[str, Any]] = {'activation_cls': {'choices': [<class 'torch.nn.modules.activation.ReLU'>, <class 'torch.nn.modules.activation.LeakyReLU'>], 'type': 'categorical'}, 'decomposition': {'choices': ['bases', 'blocks'], 'type': 'categorical'}, 'edge_dropout': {'high': 0.9, 'low': 0.0, 'type': <class 'float'>}, 'edge_weighting': {'choices': ['inverse_in_degree', 'inverse_out_degree', 'symmetric'], 'type': 'categorical'}, 'embedding_dim': {'high': 512, 'low': 32, 'q': 32, 'type': <class 'int'>}, 'interaction': {'choices': ['distmult', 'complex', 'ermlp'], 'type': 'categorical'}, 'num_layers': {'high': 5, 'low': 1, 'q': 1, 'type': <class 'int'>}, 'self_loop_dropout': {'high': 0.9, 'low': 0.0, 'type': <class 'float'>}, 'use_batch_norm': {'type': 'bool'}, 'use_bias': {'type': 'bool'}}

The default strategy for optimizing the model”s hyper-parameters