-
Hi Matt, I'm trying to make a simple classification GNN, which is similar to
My GNN looks like this : class Encodr(nn.Module):
def __init__(self):
super(Encodr,self).__init__()
self.conv1_out = 32
self.conv2_out = 64
self.conv3_out = 64
self.fc1_hidden = 128
self.x_lat = 10
self.kernel_size = 5
self.pool_reduce = 'max'
self.conv1 = SplineConv(1, self.conv1_out, dim=2, kernel_size=self.kernel_size)
self.conv2 = SplineConv(self.conv1_out, self.conv2_out, dim=2, kernel_size=self.kernel_size)
self.conv3 = SplineConv(self.conv2_out, self.conv3_out, dim=2, kernel_size=self.kernel_size)
self.fc1 = nn.Linear(self.conv3_out, self.fc1_hidden)
self.fc2 = nn.Linear(self.fc1_hidden, self.x_lat)
def forward(self,d):
x_conv1 = F.elu(self.conv1(d.x.reshape(-1,1), d.edge_index0, d.edge_attr0))
x_pool1 = scatter(x_conv1, d.cluster0,dim=0, reduce=self.pool_reduce)
x_conv2 = F.elu(self.conv2(x_pool1, d.edge_index1, d.edge_attr1))
x_pool2 = scatter(x_conv2, d.cluster1, dim=0, reduce=self.pool_reduce)
x_conv3 = F.elu(self.conv3(x_pool2, d.edge_index2, d.edge_attr2))
x_pool3 = scatter(x_conv3, d.cluster2, dim=0, reduce=self.pool_reduce)
x_fc1 = F.elu(self.fc1(x_pool3))
x_fc2 = self.fc2(x_fc1)
softmax = F.log_softmax(x_fc2, dim=1)
return softmax
def train(epoch):
model.train()
for data in train_loader:
data = data.to(device)
optimizer.zero_grad()
F.nll_loss(model(data), data.y).backward()
optimizer.step() I though it should work but I don't know what was the problematic one (it's so frustrating). Is there any wrong point here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Thanks for reporting. Can you share the pre-processing of the dataset as well? I can try to reproduce it. |
Beta Was this translation helpful? Give feedback.
Thanks for reporting. Can you share the pre-processing of the dataset as well? I can try to reproduce it.