For a multi-class classification nn.NLLLoss expects the model output to have the shape [batch_size, nb_classes] and a target in [batch_size] containing the class indices in the range [0, nb_classes-1].
Currently the model output and target both have the shape [batch_size], which will yield this error.
I’m not familiar with the model, but the last torch.sum(..., dim=1) call in GCN.forward will reduce this dimension, which might yield this issue.



 Asgard:

One more doubt that I’ve regarding this is how are the weights trained when neither the adj or features matrix have been appended with requires_grad function?


Currently, the weight and bias parameters of gc1 and gc2 will be trained, as they are registered as nn.Parameters inside the modules.
Usually you don’t need to get gradients for the inputs, so you wouldn’t need to set requires_grad=True for the features and adj tensors.