MIC-DKFZ / nnUNet

Apache License 2.0
5.68k stars 1.72k forks source link

Changing epoch number in trainer #2342

Closed thahmadalm closed 2 months ago

thahmadalm commented 3 months ago

hi fabian,

i am trying to run nnunet in google colab however i am confused how I can change the max number of epochs so the trainer doesn't run 1000 epochs. Any ideas?

I know you mentioned this "You need to create a new trainer class, derive from nnUNettrainerV2" but how can I do this?

amspsingh04 commented 3 months ago

go to nnUNet/nnunetv2/training/nnUNetTrainer/nnUNetTrainer.py find self.num_epochs = 1000 change to 2000 if you like or use this nnUNetv2_train dataset_id 3d_fullres num_fold -tr nnUNetTrainer_2000epochs

osbm commented 2 months ago

I never understood why number of epochs had to be defined as seperate classes. It seems like it could easily be an cli argument.

amspsingh04 commented 2 months ago

yeah @osbm the second option is a cli command sorry if that wasn't clear

sahikabetul commented 2 months ago

Use that command:

nnUNetv2_train 667 2d all -p nnUNetPlansSpineMini -device mps -tr nnUNetTrainer_10epochs --npz (or 100, 50, ..., please look at the file that this parameter defined)

Tricky point !!! For only one epoch:

nnUNetv2_train 667 2d all -p nnUNetPlansSpineMini -device mps -tr nnUNetTrainer_1epoch --npz