Performs forward pass of the Graph Convolutional Network (GCN). Args: input_tensor (torch.Tensor): Input node feature matrix with shape (N, input_dim), where N is the number of nodes and input_dim is the number of input features per node. adj
(self, input_tensor, adj_mat)
| 87 | self.dropout = nn.Dropout(dropout_p) |
| 88 | |
| 89 | def forward(self, input_tensor, adj_mat): |
| 90 | """ |
| 91 | Performs forward pass of the Graph Convolutional Network (GCN). |
| 92 | |
| 93 | Args: |
| 94 | input_tensor (torch.Tensor): Input node feature matrix with shape (N, input_dim), where N is the number of nodes |
| 95 | and input_dim is the number of input features per node. |
| 96 | adj_mat (torch.Tensor): Normalized adjacency matrix of the graph with shape (N, N), representing the relationships between |
| 97 | nodes. |
| 98 | |
| 99 | Returns: |
| 100 | torch.Tensor: Output tensor with shape (N, output_dim), representing the predicted class probabilities for each node. |
| 101 | """ |
| 102 | |
| 103 | # Perform the first graph convolutional layer |
| 104 | x = self.gc1(input_tensor, adj_mat) |
| 105 | x = F.relu(x) # Apply ReLU activation function |
| 106 | x = self.dropout(x) # Apply dropout regularization |
| 107 | |
| 108 | # Perform the second graph convolutional layer |
| 109 | x = self.gc2(x, adj_mat) |
| 110 | |
| 111 | # Apply log-softmax activation function for classification |
| 112 | return F.log_softmax(x, dim=1) |
| 113 | |
| 114 | |
| 115 | def load_cora(path='./cora', device='cpu'): |
nothing calls this directly
no outgoing calls
no test coverage detected