gammagl.layers.conv.CompConv

class CompConv(in_channels, out_channels, num_relations, op='sub', add_bias=True)[source]

Paper: Composition-based Multi-Relational Graph Convolutional Networks

Code: https://github.com/MichSchli/RelationPrediction

Parameters:
  • in_channels (int) – the input dimension of the features.

  • out_channels (int) – the output dimension of the features.

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

  • op (str) – the operation used in message creation.

  • add_bias (bool) – whether to add bias.

forward(x, edge_index, edge_type=None, ref_emb=None)[source]
propagate(x, edge_index, edge_type, aggr='sum', **kwargs)[source]

Function that perform message passing.

Parameters:
  • x – input node feature.

  • edge_index – edges from src to dst.

  • aggr – aggregation type, default=’sum’, optional=[‘sum’, ‘mean’, ‘max’].

  • kwargs – other parameters dict.

message(x, edge_index, edge_type, edge_weight=None, rel_emb=None, linear=None)[source]

Function that construct message from source nodes to destination nodes.

Parameters:
  • x (tensor) – input node feature.

  • edge_index (tensor) – edges from src to dst.

  • edge_weight (tensor) – weight of each edge.

Returns:

output message.

Return type:

tensor

aggregate(msg, edge_index, num_nodes=None, aggr='sum', dim_size=None)[source]

Function that aggregates message from edges to destination nodes.

Parameters:
  • msg (tensor) – message construct by message function.

  • edge_index (tensor) – edges from src to dst.

  • num_nodes (int) – number of nodes of the graph.

  • aggr (str) – aggregation type, default = ‘sum’, optional=[‘sum’, ‘mean’, ‘max’].

Returns:

output representation.

Return type:

tensor