Skip to main content
34 events
when toggle format what by license comment
Jan 28, 2024 at 15:39 answer added Novin.Nouri timeline score: 0
Apr 7, 2023 at 18:20 answer added Prajot Kuvalekar timeline score: 2
Oct 25, 2022 at 4:22 answer added Palash Mondal timeline score: 1
Jul 19, 2022 at 1:06 history reopened Mark Rotteveel
End genocide - save Gaza
Woody1193
Jul 17, 2022 at 12:22 review Reopen votes
Jul 19, 2022 at 1:06
Jul 13, 2022 at 22:03 history left closed in review Adrian Mole
funnydman
Display Name is missing
Original close reason(s) were not resolved
Jul 11, 2022 at 7:50 review Reopen votes
Jul 13, 2022 at 22:03
Jul 11, 2022 at 7:48 history edited Mateen Ulhaq CC BY-SA 4.0
Remove "opinion based" part of question. There is a very clear idiomatic method (model.state_dict), so this popular question should be reopened. Added to review
Jul 11, 2022 at 7:43 history edited Mateen Ulhaq CC BY-SA 4.0
Shorten.
Jan 24, 2022 at 4:47 history left closed in review Adrian Mole
Perry
the Tin Man
Original close reason(s) were not resolved
Jan 13, 2022 at 10:41 review Reopen votes
Jan 24, 2022 at 4:47
Jan 13, 2022 at 10:40 history closed Zoe - Save the data dump Opinion-based
Nov 8, 2021 at 21:05 answer added Christian__ timeline score: 2
Nov 5, 2021 at 14:51 comment added Marat Zakirov Then I use torch.save(model, file) it seems to drop batchnorm/dropout parameters because I never get same result then reload the model even if I make model.eval() pytorch 1.5 version. So you should use recommended way of saving just to avoid bugs I think
Jul 15, 2021 at 9:13 answer added Konstantin Burlachenko timeline score: 0
Apr 2, 2021 at 15:54 answer added End genocide - save Gaza timeline score: 6
Jul 15, 2020 at 20:37 comment added Charlie Parker @DavidMiller actually I only need to save a nn.Sequential model. Do you know how to do that? I don't have a model class definition. For sequential I wrote this, hopefully a reputable answerer will confirm: stackoverflow.com/questions/62923052/…
Jul 14, 2020 at 9:56 comment added David Miller @CharlieParker torch.save is based on pickle. The following is from the tutorial linked above: "[torch.save] will save the entire module using Python’s pickle module. The disadvantage of this approach is that the serialized data is bound to the specific classes and the exact directory structure used when the model is saved. The reason for this is because pickle does not save the model class itself. Rather, it saves a path to the file containing the class, which is used during load time. Because of this, your code can break in various ways when used in other projects or after refactors."
Jul 13, 2020 at 18:23 comment added Charlie Parker what is wrong with using pickle?
May 21, 2020 at 18:23 answer added Joy Mazumder timeline score: 19
May 13, 2019 at 20:46 answer added harsh timeline score: 24
Apr 17, 2019 at 19:01 answer added prosti timeline score: 36
Mar 24, 2019 at 21:55 comment added whlteXbread Seems like PyTorch have addressed this a bit more explicitly in their tutorials section—there's lots of good info there that's not listed in the answers here, including saving more than one model at a time and warm starting models.
Dec 30, 2018 at 7:12 history protected Shai
Jun 6, 2018 at 12:14 history edited kmario23
edited tags
Mar 2, 2018 at 23:34 answer added Jadiel de Armas timeline score: 269
S Jul 24, 2017 at 16:33 history suggested flaudre CC BY-SA 3.0
spelling in title
Jul 24, 2017 at 14:52 review Suggested edits
S Jul 24, 2017 at 16:33
May 10, 2017 at 4:30 vote accept Wasi Ahmad
May 6, 2017 at 10:18 answer added dontloo timeline score: 408
Mar 29, 2017 at 2:01 comment added Dawei Yang I tested torch.save(model, f) and torch.save(model.state_dict(), f). The saved files have the same size. Now I am confused. Also, I found using pickle to save model.state_dict() extremely slow. I think the best way is to use torch.save(model.state_dict(), f) since you handle the creation of the model, and torch handles the loading of the model weights, thus eliminating possible issues. Reference: discuss.pytorch.org/t/saving-torch-models/838/4
Mar 18, 2017 at 17:36 comment added Dawei Yang I think it's because torch.save() save all the intermediate variables as well, like intermediate outputs for back propagation use. But you only need to save the model parameters, like weight/bias etc. Sometimes the former can be much larger than the latter.
Mar 9, 2017 at 19:31 history edited Wasi Ahmad CC BY-SA 3.0
added 197 characters in body
Mar 9, 2017 at 19:06 history asked Wasi Ahmad CC BY-SA 3.0