I am running a training script and I want to save the output tensors of my validation set after each epoch.
My script runs for an arbitrary amount of epochs so I would like to append tensors to a file after each epoch.
What is the best way to go about this?
- I could
torch.save()
to one new file every epoch, but that will create a lot of files. - I could
torch.save()
to a single file each epoch, but then I would need totorch.load()
that file each epoch to append to the single data structure and re-save it. - I could add to an ever-increasing list inside my script and
torch.save()
that each epoch, but that would use up more and more memory.
Are there better alternatives? Like appending a text representation of the output tensor and append it to a text file?