DeepRegNet / DeepReg

Medical image registration using deep learning
Apache License 2.0
566 stars 77 forks source link

Automated hyperparameter tuning #476

Closed s-sd closed 3 years ago

s-sd commented 3 years ago

Subject of the feature

What are you trying to do and how would you want to do it differently?

At MICCAI I saw a lot of interest in automated hyperparameter search/ tuning. The feature is available in several libraries but integrating it with parameters specified in the config file and with the deepreg train function is not straightforward. I suggest that we add some simple functionality that allows for an automated search procedure.

To start out we could add a simple function called something like tune_and_train which takes in a slightly modifed version of the config file. The modified config file can allow the user to specify either a range for a certain parameter or multiple values for a paramter. Then using random serach the tune_and_train function first selectes the best hyperparameters from its search and then uses these to train the network for a user defined number of epochs. To start out, we can offer this random search procedure which runs the train until a user defined number of epochs for each random combination of parameters that are selected from the user defined space for the parameters. Then the validation accuracy is used from each run to select the best combination which is then used to train the final model for a user defined number of epochs. As a starting point we can offer this functionality for a few parameters in the config file like batch size and number of channels. Then we can extend with other parameters and also other search algorithms, as required.

(Copied from Issue #424 )

Is it something you currently you cannot do?

Yes

Is this related to an issue/problem?

Originally suggested in Issue #424 comments thread

Has the feature been requested before? If yes, please provide a link to the issue.

No

If the feature request is approved, would you be willing to submit a PR? (Help can be provided if you need assistance submitting a PR)

Yes

mathpluscode commented 3 years ago

Tensorflow seems to have this https://www.tensorflow.org/tensorboard/hyperparameter_tuning_with_hparams we could have a look to see if it's easy to integrate.

mathpluscode commented 3 years ago

BTW, last time I tried some auto lr tuning with pytorch lightning https://pytorch-lightning.readthedocs.io/en/latest/lr_finder.html, the experience is not amazing tho. @sbb-gh do you know some other relevant functions ;) ?

YipengHu commented 3 years ago

BTW, last time I tried some auto lr tuning with pytorch lightning https://pytorch-lightning.readthedocs.io/en/latest/lr_finder.html, the experience is not amazing tho. @sbb-gh do you know some other relevant functions ;) ?

why not amazing?

mathpluscode commented 3 years ago

BTW, last time I tried some auto lr tuning with pytorch lightning https://pytorch-lightning.readthedocs.io/en/latest/lr_finder.html, the experience is not amazing tho. @sbb-gh do you know some other relevant functions ;) ?

why not amazing?

I was imagining some auto-tuning during the training lol... Well maybe it's my expectation problem. The tool was just choosing a lr with some data before the training, and I'm not confident about the chosen lr.

sbb-gh commented 3 years ago

@mathpluscode Apologies for the late reply. I've only tried some neural architecture search on Tensorflow, where we tune the network architecture. It was a nightmare to use.

sbb-gh commented 3 years ago

Maybe just having a systematic approach would be good enough.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

mathpluscode commented 3 years ago

We did encounter many problems in demo with the loss weights, thus this issue is still important.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

s-sd commented 3 years ago

@mathpluscode @YipengHu I would be quite interested in working on this. Is it okay if I assign myself for this issue?

YipengHu commented 3 years ago

@mathpluscode @YipengHu I would be quite interested in working on this. Is it okay if I assign myself for this issue?

Thanks! Can we have a quick discussion on this? I'm aware @mathpluscode and I might have some diverging opinions on this? ;)

YipengHu commented 3 years ago

@s-sd do you have a reference for the work you mentioned?

s-sd commented 3 years ago

@YipengHu yes, we can have a discussion. Do you mean a reference for the MICCAI works exploring hyper-parameter tuning?

mathpluscode commented 3 years ago

@s-sd 😁any updates? Some papers we can check?

s-sd commented 3 years ago

@s-sd grinany updates? Some papers we can check?

@mathpluscode @YipengHu I am listing some titles for papers from MICCAI 2020. I think the best way to access them all in on place would be on the MICCAI 2020 pathable portal. If you can't access the portal, let me know and I'll try to find alternative springer or arxiv links for these.

A few other resources that I found useful (including some tools that have good documentation and provide automated tuning and also including some resources that you've shared with me previously):

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.