- avalanche.training.checkpoint.maybe_load_checkpoint(strategy, fname, map_location=None)
Load the strategy state from a checkpoint file.
The method returns the strategy with the state deserialized from the file and the index of the training experience to resume training.
If the file does not exists, the method returns the strategy unmodified and the index 0. As a result, the method can be safely called even if no checkpoint has been previously created (e.g. during the first run).
``` strategy = Naive(model, opt, train_mb_size=128) strategy, initial_exp = maybe_load_checkpoint(strategy, fname)
- for exp in benchmark.train_stream[initial_exp:]:
strategy.train(exp) save_checkpoint(strat, fname)
strategy – strategy to load. It must be already initialized.
fname – file name
map_location – sets the location of the tensors after serialization. Same as map_location of torch.load, except that you can also pass a device object or a string (a proper map will be created accordingly). The recommended way to use this parameter is to pass the used reference device. In addition, all torch.device objects will be un-pickled using that map (this is not usually done by torch.load, but it is needed to properly manage things in Avalanche). Defaults to None, which means that no mapping will take place.
tuple <strategy, exp_counter> strategy after deserialization, index of the current experience to resume training.