will
September 1, 2020, 3:54pm
1
Is it possible to create a script backed by a Trainer
object for computing the model output on all items in a Dataset
object?
Imagine I have a CNN trained for image classification and I want to save the logits over each example in the validation set.
dilip
September 1, 2020, 4:12pm
2
Would this work? If you gather all your predicted probabilities and targets in your validation step, you could override the epoch end method for validation to aggregate them and save them to file.
goku
September 1, 2020, 5:53pm
3
pvnieo
November 30, 2020, 9:05am
4
Hi @goku
After the update to V1.0, the Result object is deprecated. What is the new way to write result to disk?
goku
November 30, 2020, 6:49pm
5
self.write_prediction
in LightningModule
. It’s not documented yet.
1 Like
I couldn’t find the code of the write_prediction
method.
Assuming that it dumps the data onto disk at every call without using asynchronous process, isn’t it inefficient?
I’m using the code of @will , and I found a hack to get my job done. However, I was wondering if I want to accumulate predictions
Can I gather them into an attribute of the Trainer instance, i.e. self
? Any caveats with that approach namely as part of a distributed setup?
goku
January 14, 2021, 12:41pm
7
code for write_prediction
: lightning/lightning.py at 71d5cc11f13c1338fbe3f74a8d12e438cc6fddef · Lightning-AI/lightning · GitHub
it won’t dump at every call, it will gather it in _step
methods and saves it in _epoch_end
.
BTW there is an open PR regarding prediction you might want to check out: https://github.com/PyTorchLightning/pytorch-lightning/pull/5468
1 Like
Thanks. That’s very informative.
goku
January 15, 2021, 9:05pm
9
not sure… internal API has changed a lot since then. But I guess you don’t need to change too much of your code to make it compatible with the current version.
Thanks, so far it works OK.
Do you know how hard is to upgrade to >= 1.0.0?
I’m new with pl any tips would be relevant.
goku
January 18, 2021, 5:52pm
11
not too hard… it’s just more simplified now, mostly the logging section. you can check the examples in the repo. In case you need help, you can always ask questions on forums or on slack.