HI. I’m new at geometric deep learning and gcnn. I want to train a gcnn model for predicting a feature as a regression problem. my code is below
import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv
class GCN(torch.nn.Module):
def __init__(self):
super().__init__()
self.conv1 = GCNConv(data.num_node_features, 100)
self.conv2 = GCNConv(100, 16)
self.conv3 = GCNConv(16, data.num_node_features)
self.linear1 = torch.nn.Linear(104,1)
def forward(self, data):
x, edge_index = data.x, data.edge_index
x = self.conv1(x, edge_index)
x = F.relu(x)
x = F.dropout(x, training=self.training)
x = self.conv2(x, edge_index)
x = self.conv3(x, edge_index)
x = self.linear1(x)
return F.log_softmax(x, dim=1)
import torch.nn as nn
device = torch.device('cpu')
model = GCN().to(device)
model = model.double()
data = data.to(device)
optimizer = torch.optim.Adam(model.parameters(), lr=0.01, weight_decay=5e-4)
model.train()
for epoch in range(5):
optimizer.zero_grad()
out = model(data)
loss = F.mse_loss(out.squeeze(), data.y.squeeze())
loss.backward()
optimizer.step()
print(f'Epoch: {epoch}, Loss: {loss}')
I am getting nan loss. what are the problems with this?
Also is there any blogs of solving regression problem using pytorch geometric?
Thanks