Hi, I’m new to PyTorch and I was trying to create a simple classifier to determine the predominance of each emotional state in a person. My data consists in 32 means of frequency bins from an FFT done on EEG data. Data has 3 labels [1,0], [0,1] and [0.5,0.5] (meaning that the first labels share predominance in the data). I’ve tried various learning rates, EPOCHS, hidden layers and batch sizes. Loss is not lowering during training, and when testing on the training data outputs are all close to [0.5,0.5]. The code is here:
class Net(nn.Module): def __init__(self): super().__init__() self.fc1 = nn.Linear(32, 16) self.fc2 = nn.Linear(16, 16) self.fc3 = nn.Linear(16, 8) self.fc4 = nn.Linear(8, 2) def forward(self, x): x = F.relu(self.fc1(x)) x = F.relu(self.fc2(x)) x = F.relu(self.fc3(x)) x = self.fc4(x) return F.softmax(x, dim=1) net = Net() criterion = nn.MSELoss() optimizer = optim.SGD(net.parameters(), lr=.001, momentum=0.9) EPOCHS = 2 net.train() for epoch in range(EPOCHS): for X, y in trainset: optimizer.zero_grad() output = net(X.view(-1, 32)) loss = criterion(output, y) loss.backward() optimizer.step() print(loss)
Thanks in advance!