BlockDecomposition
- class BlockDecomposition(input_dim, num_relations, num_blocks=None, output_dim=None)[source]
Bases:
pykeen.nn.message_passing.Decomposition
Represent relation-specific weight matrices via block-diagonal matrices.
The block-diagonal decomposition restricts each transformation matrix to a block-diagonal-matrix, i.e.,
\[\mathbf{W}_r^l = diag(\mathbf{B}_{r,1}^l, \ldots, \mathbf{B}_{r,B}^l)\]where \(\mathbf{B}_{r,i} \in \mathbb{R}^{(d^{(l) }/ B) \times (d^{(l)} / B)}\).
Initialize the layer.
- Parameters
Methods Summary
forward
(x, source, target, edge_type[, ...])Relation-specific message passing from source to target.
Reset the parameters of this layer.
Methods Documentation
- forward(x, source, target, edge_type, edge_weights=None, accumulator=None)[source]
Relation-specific message passing from source to target.
- Parameters
x (
FloatTensor
) – shape: (num_nodes, input_dim) The node representations.source (
LongTensor
) – shape: (num_edges,) The source indices.target (
LongTensor
) – shape: (num_edges,) The target indices.edge_type (
LongTensor
) – shape: (num_edges,) The edge types.edge_weights (
Optional
[FloatTensor
]) – shape: (num_edges,) Precomputed edge weights.accumulator (
Optional
[FloatTensor
]) – shape: (num_nodes, output_dim) a pre-allocated output accumulator. may be used if multiple different message passing steps are performed and accumulated by sum. If none is given, create an accumulator filled with zeroes.
- Return type
FloatTensor
- Returns
shape: (num_nodes, output_dim) The enriched node embeddings.