# Regression using Pytorch Geometric

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)

model.train()
for epoch in range(5):
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

The usage of `F.log_softmax` looks wrong or at least uncommon for a regression use case. Could you describe what your target is containing?

Moreover, I tried not using `F.log_softmax`