ge-xing / Diff-UNet

Diff-UNet: A Diffusion Embedded Network for Volumetric Segmentation. (using diffusion for 3D medical image segmentation)
Apache License 2.0
149 stars 21 forks source link

How training can continue based on saved training parameters when training is interrupted. #38

Closed Worker-Hou closed 3 months ago

Worker-Hou commented 3 months ago

Questions above, thank you for your answer!

Worker-Hou commented 3 months ago

Which part of the code should be changed?

ge-xing commented 3 months ago

The init section of the Trainer class. When you have gotten a model, and then you can load the previous weight.

Worker-Hou commented 3 months ago

The init section of the Trainer class. When you have gotten a model, and then you can load the previous weight.

Sorry, I tried to call the (load_state_dict) method in the (init) function of (Trainer) in (Trainer. But still not from the previously trained weight part to continue training. Please tell me how you modified this part of the code, thank you very much!

ge-xing commented 3 months ago
image

After you have a model, you can call the load_state_dict() function to load the previous parameters.

Worker-Hou commented 3 months ago
image

After you have a model, you can call the load_state_dict() function to load the previous parameters.

Thank you for your reply. I have solved the problem. This may have been because every time I called the previous weight file, the Epoch number would start from 0 again, which made me think that it did not run successfully. However, I find that loss is the value of the previous pre-training weight, so it is successful for now! Thanks again for your reply!