| 31 | D: The degree matrix. |
| 32 | """ |
| 33 | def __init__(self, input_dim, output_dim, use_bias=False): |
| 34 | super(GraphConv, self).__init__() |
| 35 | |
| 36 | # Initialize the weight matrix W (in this case called `kernel`) |
| 37 | self.kernel = nn.Parameter(torch.Tensor(input_dim, output_dim)) |
| 38 | nn.init.xavier_normal_(self.kernel) # Initialize the weights using Xavier initialization |
| 39 | |
| 40 | # Initialize the bias (if use_bias is True) |
| 41 | self.bias = None |
| 42 | if use_bias: |
| 43 | self.bias = nn.Parameter(torch.Tensor(output_dim)) |
| 44 | nn.init.zeros_(self.bias) # Initialize the bias to zeros |
| 45 | |
| 46 | def forward(self, input_tensor, adj_mat): |
| 47 | """ |