Skip to content

Commit 83ff2f5

Browse files
authored
Minor improvement of the GCN doc (#1231)
minor improvement of the gcn doc
1 parent 8c246ba commit 83ff2f5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

gcn/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class GraphConv(nn.Module):
2828
input features per node.
2929
A: Adjacency matrix of the graph with shape (N, N), representing the relationships between nodes.
3030
W: Learnable weight matrix with shape (F_in, F_out), where F_out is the number of output features per node.
31+
D: The degree matrix.
3132
"""
3233
def __init__(self, input_dim, output_dim, use_bias=False):
3334
super(GraphConv, self).__init__()
@@ -48,7 +49,7 @@ def forward(self, input_tensor, adj_mat):
4849
4950
Args:
5051
input_tensor (torch.Tensor): Input tensor representing node features.
51-
adj_mat (torch.Tensor): Adjacency matrix representing graph structure.
52+
adj_mat (torch.Tensor): Normalized adjacency matrix representing graph structure.
5253
5354
Returns:
5455
torch.Tensor: Output tensor after the graph convolution operation.
@@ -92,7 +93,7 @@ def forward(self, input_tensor, adj_mat):
9293
Args:
9394
input_tensor (torch.Tensor): Input node feature matrix with shape (N, input_dim), where N is the number of nodes
9495
and input_dim is the number of input features per node.
95-
adj_mat (torch.Tensor): Adjacency matrix of the graph with shape (N, N), representing the relationships between
96+
adj_mat (torch.Tensor): Normalized adjacency matrix of the graph with shape (N, N), representing the relationships between
9697
nodes.
9798
9899
Returns:
@@ -113,7 +114,7 @@ def forward(self, input_tensor, adj_mat):
113114

114115
def load_cora(path='./cora', device='cpu'):
115116
"""
116-
The graph convolutional operation rquires normalize the adjacency matrix: D^(-1/2) * A * D^(-1/2). This step
117+
The graph convolutional operation rquires the normalized adjacency matrix: D^(-1/2) * A * D^(-1/2). This step
117118
scales the adjacency matrix such that the features of neighboring nodes are weighted appropriately during
118119
aggregation. The steps involved in the renormalization trick are as follows:
119120
- Compute the degree matrix.
@@ -249,7 +250,7 @@ def test(model, criterion, input, target, mask):
249250
idx = torch.randperm(len(labels)).to(device)
250251
idx_test, idx_val, idx_train = idx[:1000], idx[1000:1500], idx[1500:]
251252

252-
gcn = GCN(features.shape[1], args.hidden_dim, labels.max().item() + 1,args.include_bias, args.dropout_p).to(device)
253+
gcn = GCN(features.shape[1], args.hidden_dim, labels.max().item() + 1, args.include_bias, args.dropout_p).to(device)
253254
optimizer = Adam(gcn.parameters(), lr=args.lr, weight_decay=args.l2)
254255
criterion = nn.NLLLoss()
255256

0 commit comments

Comments
 (0)