New issue
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
Trial predict fails with the given example #616
Comments
Hi, thanks for the issue! We think this may relate to some old bugs that have since been fixed. Could I get you to update your torchbearer version with |
@ethanwharris Thanks for your instruction. from torchbearer import Trial
test_data = torch.rand(5, 5)
t = Trial(None).with_test_data(test_data)
test_predictions = t.predict(data_key=torchbearer.TEST_DATA)
>>>TypeError: expected Tensor as element 0 in argument 0, but got NoneType |
Hi, the example uses a None model which doesn't actually make predictions, so the code that aggregates predictions across batches has trouble with it. This code with a model that returns a tensor should give you the predictions properly, so it should work with the original model you wanted predictions from. The predict method should definitely deal with the None model better though so I've put up a PR to deal with it. It'll now just return a list of the model outputs for each batch if it can't combine them into a single tensor. Thanks for bringing this to our attention! |
Oops, sorry @danielhuoo , just realised you said you got the same error from your code too. Could you post a sample of it so we can have a look? |
@MattPainter01 Thanks for your "Oops". |
After training the model, I want to get the prediction on the test set. Not the accuracy. I know that should be
Trial.evaluate()
. It works well. Therefore I usedTrial.predict()
. Is that right?But the error says that
AttributeError: 'dict' object has no attribute 'data'
.I read the instruction of Trial that provides an example,
I ran it but got an error
AttributeError: 'NoneType' object has no attribute 'eval'
So, is there any problem in this method?
The text was updated successfully, but these errors were encountered: