fourson / DeblurGAN-pytorch

An easy-to-read implementation of DeblurGAN
56 stars 16 forks source link

Save latest checkpoints #5

Closed tqdungctuct closed 3 years ago

tqdungctuct commented 3 years ago

I want to create latest checkpoint after every epochs beside save period in config file. For example, I already set save period every 10 epochs but I still want to create latest checkpoint for every epoch. Can you guide me to do that? Thank you

fourson commented 3 years ago

Just set the ``save_period'' flag to 1 so that you can save the checkpoint file every epoch.

tqdungctuct commented 3 years ago

Thank @fourson . But I also want to have the checkpoint after 10 epochs. My idea is latest checkpoint will be overwrited after next epoch is done. If change save period to 1, the problem is many save file is created and it take a lot of space

fourson commented 3 years ago

You can add some logics in base/base_trainer.py at function ``train''.

tqdungctuct commented 3 years ago

You can add some logics in base/base_trainer.py at function ``train''.

Can you take a little time to help me do that? I don't know much about coding so I can't write it. I appreciate you so much

fourson commented 3 years ago

Just set the flag ``is_best'' to True manually (keep it always True) so that the file model_best.pth will always contain the newest checkpoint.

tqdungctuct commented 3 years ago

https://github.com/fourson/DeblurGAN-pytorch/blob/2eb6db58e5be8e12cb4de5a4aded9e3b949a955f/base/base_trainer.py#L120

This line, right?

tqdungctuct commented 3 years ago

@fourson I still have to set save_period to 1 to make it work. Here is detail of my idea. Can you guide me how to implement it? For example, after epoch 1 complete, it will create latest.pth, model_best.pth. After epoch 2, new latest.pth will create and overwrite the old one, model_best.pth .... After epoch 10, checkpoint_epoch10.pth will be created, also latest.pth and model_best.pth created too

fourson commented 3 years ago

Set is_best to True in code and set save_period to 10 in config simultaneously.