Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

40-validation-early-stop #73

Merged
merged 5 commits into from
Feb 13, 2020
Merged

40-validation-early-stop #73

merged 5 commits into from
Feb 13, 2020

Conversation

madil90
Copy link
Contributor

@madil90 madil90 commented Feb 12, 2020

Fixes #40 fixes #8

Description

Added example for model validation every step with metric logging. Added util functions for early stopping.

Status

Ready

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or new feature that would cause existing functionality to change)
  • New tests added to cover the changes
  • Docstrings/Documentation updated

with this PR, running the training program gives:

MONAI version: 0.0.1                                                                                                                                                                                                                                          Python version: 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:30:03)  [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
Numpy version: 1.18.1                                                                                                                                                                                                                                         Pytorch version: 1.4.0                                                                                                                                                                                                                                        
Ignite version: 0.3.0                                                                                                        
torch.Size([10, 1, 64, 64, 64]) torch.Size([10, 1, 64, 64, 64])                                                              
INFO:ignite.engine.engine.Engine:Engine run starting with max_epochs=3.                                                      
INFO:ignite.engine.engine.Engine:Epoch[1] Complete. Time taken: 00:00:37                                                       
INFO:ignite.engine.engine.Engine:Epoch[1] Metrics -- Training Dice: 0.1323                                                     
INFO:ignite.engine.engine.Engine:Epoch[1] Loss: 0.9143436551094055                                                             
INFO:ignite.engine.engine.Engine:Engine run starting with max_epochs=1.                                                        
INFO:ignite.engine.engine.Engine:Epoch[1] Complete. Time taken: 00:00:19                                                       
INFO:ignite.engine.engine.Engine:Epoch[1] Metrics -- Mean Dice: 0.1433                                                         
INFO:ignite.engine.engine.Engine:Engine run complete. Time taken 00:00:19                                                      
INFO:ignite.engine.engine.Engine:Epoch: 2/3, Iter: 1/3 -- Training Dice: 0.1323                                                
INFO:ignite.engine.engine.Engine:Epoch: 2/3, Iter: 2/3 -- Training Dice: 0.1323                                                
INFO:ignite.engine.engine.Engine:Epoch: 2/3, Iter: 3/3 -- Training Dice: 0.1323                                                
INFO:ignite.engine.engine.Engine:Epoch[2] Complete. Time taken: 00:00:39                                                       
INFO:ignite.engine.engine.Engine:Epoch[2] Metrics -- Training Dice: 0.1296                                                     
INFO:ignite.engine.engine.Engine:Epoch[2] Loss: 0.9668307900428772                                                             
INFO:ignite.engine.engine.Engine:Engine run starting with max_epochs=1.                                                        
INFO:ignite.engine.engine.Engine:Epoch[1] Complete. Time taken: 00:00:19                                                       
INFO:ignite.engine.engine.Engine:Epoch[1] Metrics -- Mean Dice: 0.1426                                                         
INFO:ignite.engine.engine.Engine:Engine run complete. Time taken 00:00:19                                                      
INFO:ignite.engine.engine.Engine:Epoch: 3/3, Iter: 1/3 -- Training Dice: 0.1296                                                
INFO:ignite.engine.engine.Engine:Epoch: 3/3, Iter: 2/3 -- Training Dice: 0.1296                                                
INFO:ignite.engine.engine.Engine:Epoch: 3/3, Iter: 3/3 -- Training Dice: 0.1296                                                
INFO:ignite.engine.engine.Engine:Epoch[3] Complete. Time taken: 00:00:39                                                       
INFO:ignite.engine.engine.Engine:Epoch[3] Metrics -- Training Dice: 0.1686                                                     
INFO:ignite.engine.engine.Engine:Epoch[3] Loss: 0.825812816619873                                                              
INFO:ignite.engine.engine.Engine:Engine run starting with max_epochs=1.                                                        
INFO:ignite.engine.engine.Engine:Epoch[1] Complete. Time taken: 00:00:19                                                       
INFO:ignite.engine.engine.Engine:Epoch[1] Metrics -- Mean Dice: 0.1430                                                         
INFO:ignite.engine.engine.Engine:Engine run complete. Time taken 00:00:19                                                      
INFO:ignite.engine.engine.Engine:Engine run complete. Time taken 00:02:56

@madil90 madil90 requested review from ericspod and Nic-Ma February 12, 2020 00:24
@madil90 madil90 changed the title Adding MVP example for Validation every epoch with Early Stopping. 40-validation-early-stop Feb 12, 2020
monai/utils/stopperutils.py Outdated Show resolved Hide resolved
monai/utils/stopperutils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Nic-Ma Nic-Ma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @madil90 ,

Thanks for your quick PR, I just added 2 comments inline, could you please help take a look?
Thanks.

@wyli
Copy link
Contributor

wyli commented Feb 12, 2020

@madil90 could you update examples/unet_segmentation_3d.py with the same content from the notebook? it's difficult to handle the conflicts if multiple branches modify the notebook

Copy link
Contributor

@Nic-Ma Nic-Ma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me for current MVP version.
We may need to refactor utils part in later sprints.
And define unified format for model output, then we can use the util function "stopping_fn_from_loss".
Thanks.

@Nic-Ma Nic-Ma self-requested a review February 13, 2020 02:08
Copy link
Contributor

@Nic-Ma Nic-Ma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me for current MVP version.
We may need to refactor utils part in later sprints.
And define unified format for model output, then we can use the util function "stopping_fn_from_loss".
Thanks.

@madil90 madil90 force-pushed the 40-validation-handler branch from db5d9b2 to 4175142 Compare February 13, 2020 07:42
@Nic-Ma Nic-Ma self-requested a review February 13, 2020 13:56
Copy link
Contributor

@Nic-Ma Nic-Ma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me.

@Nic-Ma Nic-Ma requested a review from wyli February 13, 2020 13:58
@madil90 madil90 merged commit 5e12c5d into master Feb 13, 2020
@wyli wyli deleted the 40-validation-handler branch April 6, 2020 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants