SMART-Lab / smartlearner

SMART-Learner is a machine learning library built with researchers in mind.
BSD 3-Clause "New" or "Revised" License
10 stars 4 forks source link

Added save and load functions to the framework. #62

Closed MarcCote closed 8 years ago

MarcCote commented 8 years ago

This PR allows you to save and load an experiment. Basically, it allows to save/load the state of the following classes: Trainer, Optimizer, BatchScheduler, Loss, Model, andTask`.

trainer = ... # Create a trainer
trainer.train()  # Train it for some time
trainer.save(path)  # Manually save the trainer (or via a task)
# Crash/Quit
trainer = ... # Rebuild the trainer
trainer.load(path)  # Load previous state of the trainer
trainer.train()  # Resume training

For a complete example, check function test_resume_experiment in smartlearner/tests/test_smartlearner.py .

Note: this PR break backward compatibility if your models were defining the load method. To be coherent with the rest of the framework load is now a method (opposed to a classmethod) that "replaces" the parameters value of an existing instance of Model. To create a new instance from data saved on disk, one can use the new method create (to be implemented by the subclasses).

MarcCote commented 8 years ago

@ASalvail this one

ASalvail commented 8 years ago

There you go, some questions/suggestions/insights.

MarcCote commented 8 years ago

@ppoulin91 I added the following test to check your comment "Define sigma_t, decaying at each timestep" but it's failing. can you have a look?

ppoulin91 commented 8 years ago

@MarcCote I'll have a look