How to store and access multiple values in a single pt file?

How do I store 7 tensors and load whichever tensor i need? For example, I should be able to load the 5th tensor if I want to.


You can use (docs here: — PyTorch 2.0 documentation) and just pass all your tensors within a dict object and serialize the dictionary, for example,{'tensor1':tensor1, 'tensor2':tensor2}, filename)
1 Like

How can I append values to the file at every iteration ?