GatedCombination

class GatedCombination(entity_embedding_dim, literal_embedding_dim, input_dropout=0.0, gate_activation=<class 'torch.nn.modules.activation.Sigmoid'>, gate_activation_kwargs=None, linlayer_activation=<class 'torch.nn.modules.activation.Tanh'>, linlayer_activation_kwargs=None)[source]

Bases: pykeen.nn.combinations.Combination

A module that implements a gated linear transformation for the combination of entities and literals.

Compared to the other Combinations, this combination makes use of a gating mechanism commonly found in RNNs. The main goal of this gating mechanism is to learn which parts of the additional literal information is useful or not and act accordingly, by incorporating them into the new combined embedding or discarding them.

Implementation based on https://github.com/SmartDataAnalytics/LiteralE/blob/master/model.py Gate class.

Instantiate the torch.nn.Module.

Parameters
  • entity_embedding_dim (int) – The dimension of the entity representations.

  • literal_embedding_dim (int) – The dimension of the literals.

  • input_dropout (float) – The dropout to use

  • gate_activation (Union[str, Module, Type[Module], None]) – An optional, pre-instantiated activation module, like torch.nn.Sigmoid, the class for an activation to instantiate, or the name of an activation to look up and instantiate to be used on the gate output

  • gate_activation_kwargs (Optional[Mapping[str, Any]]) – The keyword arguments to be used to instantiate the gate_activation if a class or name is given instead of a pre-instantiated activation module

  • linlayer_activation (Union[str, Module, Type[Module], None]) – An optional, pre-instantiated activation module, like torch.nn.Tanh, the class for an activation to instantiate, or the name of an activation to look up and instantiate to be used on the gate output

  • linlayer_activation_kwargs (Optional[Mapping[str, Any]]) – The keyword arguments to be used to instantiate the linlayer_activation if a class or name is given instead of a pre-instantiated activation module

Methods Summary

forward(x, literal)

Calculate a combined embedding given the entity and literal representations.

Methods Documentation

forward(x, literal)[source]

Calculate a combined embedding given the entity and literal representations.

Return type

FloatTensor