We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I first use onnx2pytorch to convert onnx to pytorch, and then use it to use the test set to get the accuracy. This is my part of code :
model = torch.load(" .pkl") model.eval() for epoch in range(1) : testing_loss = 0.0 testing_correct = 0.0 zpred, ztrue = [], [] for test_inputs, test_labels in test_data : test_inputs, test_labels = test_inputs.to(device), test_labels.to(device) output = model(test_inputs) #error poit loss = criterion(output, test_labels) _, pred = torch.max(output.data, 1) testing_loss += loss.item() testing_correct += torch.sum(pred == test_labels.data) output = (torch.max(torch.exp(output), 1)[1]).data.cpu().numpy() zpred.extend(output) testlabel = test_labels.data.cpu().numpy() ztrue.extend(testlabel) test_loss = testing_loss / len(test_loader) test_acc = 100 * testing_correct.cpu().numpy() / len(test_loader) print('Epoch is : {}, Test Loss is : {:.4f} Test Accuracy is :{:.4f}%'.format(epoch + 1, test_loss, test_acc))
But I got this error :
sum() received an invalid combination of arguments - got (Tensor, Tensor), but expected one of : * (Tensor input, *, torch.dtype dtype) * (Tensor input, tuple of ints dim, bool keepdim, *, torch.dtype dtype, Tensor out) * (Tensor input, tuple of names dim, bool keepdim, *, torch.dtype dtype, Tensor out)
How can I change the second tensor to the expected attribute?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I first use onnx2pytorch to convert onnx to pytorch, and then use it to use the test set to get the accuracy.
This is my part of code :
But I got this error :
How can I change the second tensor to the expected attribute?
The text was updated successfully, but these errors were encountered: