Starting from 0, little knowledge of pytorch but some knowledge about key concepts thanks to deeplearning course of Andrew Ng.
https://docs.dgl.ai/tutorials/basics/1_first.html
Q1. Can you clarify how / when functions forward() of classes for GCNLayer and GCN model are called ?
Look at the python code dfining the classes for GCNLayer and GCN model.
A net is defined by passing the number or tensors ( corresponding to number of nodes ), size of hidden layer and final size of output, here 2 as a binary classifier.
example for a network of 34 nodes in Zachary demo:
net = GCN(34, 5, 2)
but then inputs to the model are fed like this:
logits = net(G, inputs)
Why not like by calling the forward functions, like this: logits = net**.forward**(G, inputs)
?
Q2. ** Understanding how the model works **
By reading at the description of a GCN by Kipf and Welling, I understand a message-passing model computes, at each step (layer) a convolution of vectors associated to node’s neighbours into a “resulting” node’s property.
I am reading at pytorch documentation about the Functional model
https://pytorch.org/docs/stable/nn.functional.html
https://pytorch.org/docs/stable/nn.html
and reading code here:
[...]
logits = net(G, inputs)
# we save the logits for visualization later
all_logits.append(logits.detach())
logp = F.log_softmax(logits, 1)
# we only compute loss for labeled nodes
loss = F.nll_loss(logp[labeled_nodes], labels)
optimizer.zero_grad()
loss.backward()
optimizer.step()
[...]
I don’t understand how forward is computed in the gradient descent.
How the forward funciton are called?
Where the convolution are applied ?
(I suspect in the GCNLayer, but willing to understand better how it works, also in terms of how code structured respect to pytorch apis).
Thank you