Viewing a single comment thread. View all comments

seraschka t1_iuxf2c3 wrote

> I need to give in input to the neural network also info about connections among data (an adjacency matrix) in addition to the data themselves.

Yup :). In a nutshell, you can think of the forward pass as

  def forward(self, X, A):
    potential_msgs = torch.mm(X, self.W2)
    propagated_msgs = torch.mm(A, potential_msgs)
    root_update = torch.mm(X, self.W1)
    output = propagated_msgs + root_update + self.bias
    return output

where A is the adjacency matrix.

PS: I have a code notebook on coding a simple graph neural net from scratch if useful: https://github.com/rasbt/machine-learning-book/blob/main/ch18/ch18_part1.ipynb

5

nbviewerbot t1_iuxf3o0 wrote

I see you've posted a GitHub link to a Jupyter Notebook! GitHub doesn't render large Jupyter Notebooks, so just in case, here is an nbviewer link to the notebook:

https://nbviewer.jupyter.org/url/github.com/rasbt/machine-learning-book/blob/main/ch18/ch18%5C_part1.ipynb

Want to run the code yourself? Here is a binder link to start your own Jupyter server and try it out!

https://mybinder.org/v2/gh/rasbt/machine-learning-book/main?filepath=ch18%2Fch18%5C_part1.ipynb


^(I am a bot.) ^(Feedback) ^(|) ^(GitHub) ^(|) ^(Author)

3