In train phase the model is showing 0.8 accuracy but in test phase the accuracy is reduced to 0.2
Is there any thing wrong in my code.
test_iterator = torch.utils.data.TensorDataset(x_test, y_test.reshape(-1).long())
test_data = torch.utils.data.DataLoader(test_iterator, batch_size = 64, shuffle = True)
Test the model
model.eval()
#with torch.no_grad():
accuracy = 0
for features, labels in test_data:
outputs = model(features)
accuracy += (outputs.argmax(1) == labels).float().mean()
print(f’Accuracy: {(accuracy/batches):.8f}’)