GOOD.networks.models.GCNs
The Graph Neural Network from the “Semi-supervised Classification with Graph Convolutional Networks” paper.
Classes
|
The Graph Neural Network from the "Semi-supervised Classification with Graph Convolutional Networks" paper. |
|
The graph convolutional operator from the `"Semi-supervised |
|
The GCN encoder using the |
|
GCN feature extractor using the |
- class GOOD.networks.models.GCNs.GCN(config: Union[CommonArgs, Munch])[source]
Bases:
GNNBasic
The Graph Neural Network from the “Semi-supervised Classification with Graph Convolutional Networks” paper.
- Parameters
config (Union[CommonArgs, Munch]) – munchified dictionary of args (
config.model.dim_hidden
,config.model.model_layer
,config.dataset.dim_node
,config.dataset.num_classes
)
- forward(*args, **kwargs) Tensor [source]
The GCN model implementation.
- Parameters
*args (list) – argument list for the use of arguments_read. Refer to
arguments_read
**kwargs (dict) – key word arguments for the use of arguments_read. Refer to
arguments_read
- Returns (Tensor):
label predictions
- class GOOD.networks.models.GCNs.GCNConv(*args, **kwargs)[source]
Bases:
GCNConv
- The graph convolutional operator from the `”Semi-supervised
Classification with Graph Convolutional Networks” <https://arxiv.org/abs/1609.02907>`_ paper
- Parameters
- Shapes:
input: node features \((|\mathcal{V}|, F_{in})\), edge indices \((2, |\mathcal{E}|)\), edge weights \((|\mathcal{E}|)\) (optional)
output: node features \((|\mathcal{V}|, F_{out})\)
- forward(x: Tensor, edge_index: Union[Tensor, SparseTensor], edge_weight: Optional[Tensor] = None) Tensor [source]
The GCN graph convolutional operator.
- Parameters
x (Tensor) – node features
edge_index (Tensor) – edge indices
edge_weight (Tensor) – edge weights
- Returns (Tensor):
node feature representations
- propagate(edge_index: Union[Tensor, SparseTensor], size: Optional[Tuple[int, int]] = None, **kwargs)[source]
The initial call to start propagating messages.
- Parameters
edge_index (Tensor or SparseTensor) – A
torch.LongTensor
or atorch_sparse.SparseTensor
that defines the underlying graph connectivity/message passing flow.edge_index
holds the indices of a general (sparse) assignment matrix of shape[N, M]
. Ifedge_index
is of typetorch.LongTensor
, its shape must be defined as[2, num_messages]
, where messages from nodes inedge_index[0]
are sent to nodes inedge_index[1]
(in caseflow="source_to_target"
). Ifedge_index
is of typetorch_sparse.SparseTensor
, its sparse indices(row, col)
should relate torow = edge_index[1]
andcol = edge_index[0]
. The major difference between both formats is that we need to input the transposed sparse adjacency matrix intopropagate()
.size (tuple, optional) – The size
(N, M)
of the assignment matrix in caseedge_index
is aLongTensor
. If set toNone
, the size will be automatically inferred and assumed to be quadratic. This argument is ignored in caseedge_index
is atorch_sparse.SparseTensor
. (default:None
)**kwargs – Any additional data which is needed to construct and aggregate messages, and to update node embeddings.
- class GOOD.networks.models.GCNs.GCNEncoder(config: Union[CommonArgs, Munch])[source]
Bases:
BasicEncoder
The GCN encoder using the
GCNConv
operator for message passing.- Parameters
config (Union[CommonArgs, Munch]) – munchified dictionary of args (
config.model.dim_hidden
,config.model.model_layer
,config.dataset.dim_node
)
- class GOOD.networks.models.GCNs.GCNFeatExtractor(config: Union[CommonArgs, Munch])[source]
Bases:
GNNBasic
GCN feature extractor using the
GCNEncoder
.- Parameters
config (Union[CommonArgs, Munch]) – munchified dictionary of args (
config.model.dim_hidden
,config.model.model_layer
,config.dataset.dim_node
)
- forward(*args, **kwargs)[source]
GCN feature extractor using the
GCNEncoder
.- Parameters
*args (list) – argument list for the use of arguments_read. Refer to
arguments_read
**kwargs (dict) – key word arguments for the use of arguments_read. Refer to
arguments_read
- Returns (Tensor):
node feature representations