Info on training set stored on saved model?

Dear all, I am doing a lot of experiments (vision), and sometimes I forget to document what I did, e…g., variations in the training set. Is there any information on the training set stored in the .pkl or .pth model? Total number of images, or images per class, would be sufficient for me to trace back to the original training set. Thanks.

1 Like

Possibly make your own custom export() function based on…

learn.export??

Signature:
learn.export(
    fname='export.pkl',
    pickle_module=<module 'pickle' from '/opt/conda/lib/python3.7/pickle.py'>,
    pickle_protocol=2,
)
Source:   
@patch
def export(self:Learner, fname='export.pkl', pickle_module=pickle, pickle_protocol=2):
    "Export the content of `self` without the items and the optimizer state for inference"
    if rank_distrib(): return # don't export if child proc
    self._end_cleanup()
    old_dbunch = self.dls
    self.dls = self.dls.new_empty()
    state = self.opt.state_dict() if self.opt is not None else None
    self.opt = None
    with warnings.catch_warnings():
        #To avoid the warning that come from PyTorch about model not being checked
        warnings.simplefilter("ignore")
        torch.save(self, self.path/fname, pickle_module=pickle_module, pickle_protocol=pickle_protocol)
    self.create_opt()
    if state is not None: self.opt.load_state_dict(state)
    self.dls = old_dbunch
File:      /opt/conda/lib/python3.7/site-packages/fastai/learner.py
Type:      method

Thanks, this would be good from now on, but not to recover info abot previously generated models… a lesson to be more systematic :slight_smile:

1 Like