Each epoch gives the same output

Here is my model and my training process, I don’t think my model is learning since it gives me the same output every epoch. Can someone help me out, please?

class Net(torch.nn.Module):
    def __init__(self, num_classes=10):
        super(Net, self).__init__()
        self.conv1 = GCNConv(2, 16)
        self.conv2 = GCNConv(16, 32)
        self.conv3 = GCNConv(32, 48)
        self.conv4 = GCNConv(48, 64)
        self.conv5 = GCNConv(64, 96)
        self.conv6 = GCNConv(96, 128)
        self.linear1 = torch.nn.Linear(128,64)
        self.linear1.weight.data.normal_(0, 0.005)
        self.linear2 = torch.nn.Linear(64,num_classes)
        self.linear2.weight.data.normal_(0, 0.005)
    def forward(self, data):
        x, edge_index = data.x, data.edge_index
        x = self.conv1(x, edge_index)
        x = F.relu(x)
        x = self.conv2(x, edge_index)
        x = F.relu(x)
        x = self.conv3(x, edge_index)
        x = F.relu(x)
        x = self.conv4(x, edge_index)
        x = F.relu(x)
        x = self.conv5(x, edge_index)
        x = F.relu(x)
        x = self.conv6(x, edge_index)
        x = F.relu(x)
        x, _ = scatter_max(x, data.batch, dim=0)
        x = self.linear1(x)
        x = F.relu(x)
        x = self.linear2(x)
        return x

And this is my training process

use_cuda=torch.cuda.is_available()
device = torch.device("cuda" if use_cuda else "cpu")
model = Net().to(device)
optimizer = torch.optim.SGD(model.parameters(), lr=LEARNING_RATE,momentum=MOMENTUM,weight_decay=WEIGHT_DECAY)
criterion = nn.CrossEntropyLoss()

for epoch in range(epoch_num):
    train_loss = 0.0
    model.train()
    for i in range(batch_number):
        batch=train_list[i][1].to(device)
        optimizer.zero_grad()
        outputs = model(batch)
        loss = criterion(output,batch.t)
        loss.backward()
        optimizer.step()


correct = 0
total = 0
batch_num = 0
loss = 0
model.eval()
    with torch.no_grad():
        for data in testloader:
            data = data.to(device)
            outputs = model(data)
            loss += criterion(outputs.embeddings[-1],data.t)
            _, predicted = torch.max(outputs.embeddings[-1], 1)
            total += data.t.size(0)
            batch_num += 1
            correct += (predicted == data.t).sum().cpu().item()

You forget to do optimizer.step() to update the model parameters. The training code should be something like:

        batch=train_list[i][1].to(device)
        optimizer.zero_grad()
        outputs = model(batch)
        loss = criterion(output,batch.t)
        loss.backward()
        # here is the missing code!
        optimizer.step()

oh sorry, it is I forgot to put this line here, it is actually in the code.

That’s strange. Maybe you can print the weight of some layers out and see if it really changes or not.