DenseBiDecoder

class graphstorm.model.DenseBiDecoder(in_units, num_classes, multilabel, target_etype, num_basis=2, dropout_rate=0.0, regression=False, norm=None, use_bias=True)

Bases: GSEdgeDecoder

Dense bi-linear decoder for edge prediction tasks.

DenseBiDecoder is the dense implementation of the bi-linear decoder used in GCMC. Suitable when the graph can be represented by a pair of lists (one for source node list and one for destination node list).

Parameters

in_units: int

The input dimension size. It is the dimension for both source and destination node. embeddings.

num_classes: int

Number of classes. For classification tasks only.

multilabel: bool

Whether this is a multi-label classification decoder.

num_basis: int

Number of basis. Default: 2.

dropout_rate: float

Dropout rate. Default: 0.

target_etype: tuple of str

The target etype for prediction in the format of (src_ntype, etype, dst_ntype).

regression: bool

Whether this decoder is for regression tasks. Default: False.

norm: str

Normalization methods. Not used, but reserved for complex DenseBiDecoder child class implementation. Default: None.

use_bias: bool

Whether the edge decoder uses a bias parameter. Default: True.

Changed in version 0.4.0: Add a new argument “use_bias” so users can control whether decoders have bias.

forward(g, h, e_h=None)

Dense bi-linear edge decoder forward computation.

Parameters

g: DGLGraph

The graph of target edges.

h: dict of Tensor

The input node embeddings in the format of {ntype: emb}.

e_h: dict of Tensor

The input edge embeddings in the format of {(src_ntype, etype, dst_ntype): emb}. Not used, but reserved for future support of edge embeddings. Default: None.

Returns

out: Tensor

The prediction results.

predict(g, h, e_h=None)

Dense bi-linear edge decoder predict computation.

Parameters

g: DGLGraph

The graph of target edges.

h: dict of Tensor

The input node embeddings in the format of {ntype: emb}.

e_h: dict of Tensor

The input edge embeddings in the format of {(src_ntype, etype, dst_ntype): emb}. Not used, but reserved for future support of edge embeddings. Default: None.

Returns

out: Tensor

The prediction results.

predict_proba(g, h, e_h=None)

Dense bi-linear edge decoder predict computation and return the normalized prediction results if this decoder is for edge classification.

Parameters

g: DGLGraph

The graph of target edges.

h: dict of Tensor

The input node embeddings in the format of {ntype: emb}.

e_h: dict of Tensor

The input edge embeddings in the format of {(src_ntype, etype, dst_ntype): emb}. Not used, but reserved for future support of edge embeddings. Default: None.

Returns

out: Tensor

The prediction results. If this decoder is for edge classification, return the normalized prediction results.

property in_dims

Return the input dimension size, which is given in class initialization.

property out_dims

Return the output dimension size. If this decoder is for edge regression, will return 1.