I am using a lstm as a classifier for timeseries data for 3 classes. I print out my predictions and labels at the end with my loss and accuracy. No matter if my Loss is 0.1 or 1.0 my accuracy is almost always 0.7142.
I am wondering if I calculated loss and accuracy correctly in my model or if this is just a problem about hyperparamter tuning. I am under a lot of time pressure so if someone could help me I would be very thankful.
My validation loop looks as follows.
EDIT: I am using CrossEntropyLoss() as criterion
for i, (inputs, labels) in enumerate(valloader):
y_pred = model(inputs)
_,prediction2 = torch.max(y_pred, 1)
labels = labels.type_as(y_pred)
labels = labels.long()
val_loss = criterion(y_pred, labels)
running_val_loss += val_loss.item()
for x in range(len(labels)):
y_true_list.append(labels[x].item())
for x in range(len(prediction2)):
y_pred_list.append(prediction2[x].item())
total += labels.size(0)
correct += (prediction2 == labels).sum().item()
#getting output for metric calc correct
softmax = nn.Softmax(dim=1)
probability = softmax(y_pred)
for x in range(len(probability)):
probability_each = probability[x].detach().numpy()
prob_softmax.append(probability_each)
val_loss_mean = running_val_loss/len(valloader)
validation_losses.append(val_loss_mean)
accuracy = (correct/total)
validation_accuracys.append(accuracy)
print("Y True and Y Pred :",y_true_list, y_pred_list)
print(f'Fold {fold}: For Epoche {epoch} the Loss is {val_loss_mean} and the Acc is {accuracy}')