Skip to content

Commit

Permalink
Guide 2: Fix Lightning documentation links
Browse files Browse the repository at this point in the history
  • Loading branch information
phlippe committed Feb 21, 2023
1 parent 5f8a7c9 commit 251194e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/tutorial_notebooks/guide2/Research_Projects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"### Argument parser\n",
"\n",
"* It is a good practice to use argument parsers for specifying hyperparameters. Argument parsers allow you to call a training like `python train.py --learning ... --seed ... --hidden_size ...` etc. \n",
"* If you have multiple models to choose from, you will have multiple set of hyperparameters. A good summary on that can be found in the [PyTorch Lightning documentation](https://pytorch-lightning.readthedocs.io/en/latest/hyperparameters.html#argparser-best-practices) without the need of using Lightning. In essence, you can define a static method for each model that returns a parser for its specific hyperparameters. This makes your code cleaner and easier to define new tasks without copying the whole argument parser.\n",
"* If you have multiple models to choose from, you will have multiple set of hyperparameters. A good summary on that can be found in the [PyTorch Lightning documentation](https://pytorch-lightning.readthedocs.io/en/latest/common/hyperparameters.html#argparser-best-practices) without the need of using Lightning. In essence, you can define a static method for each model that returns a parser for its specific hyperparameters. This makes your code cleaner and easier to define new tasks without copying the whole argument parser.\n",
"* To ensure reproducibility (more details below), it is recommended to save the arguments as a json file or similar in your checkpoint folder."
]
},
Expand All @@ -63,8 +63,8 @@
"### Toolkits\n",
"\n",
"* PyTorch Lightning provides a lot of useful tricks and toolkits on hyperparameter searching, such as:\n",
" * [Learning rate finder](https://pytorch-lightning.readthedocs.io/en/latest/lr_finder.html) that plots the learning rate vs loss for a few initial batches, and helps you to choose a reasonable learning rate.\n",
" * [Autoscaling batch sizes](https://pytorch-lightning.readthedocs.io/en/latest/training_tricks.html#auto-scaling-of-batch-size) which finds the largest possible batch size given your GPU (helpful if you have very deep, large models, and it is obvious you need the largest batch size possible).\n",
" * [Learning rate finder](https://pytorch-lightning.readthedocs.io/en/latest/advanced/training_tricks.html?highlight=Learning%20rate%20finder#learning-rate-finder) that plots the learning rate vs loss for a few initial batches, and helps you to choose a reasonable learning rate.\n",
" * [Autoscaling batch sizes](https://pytorch-lightning.readthedocs.io/en/latest/advanced/training_tricks.html#batch-size-finder) which finds the largest possible batch size given your GPU (helpful if you have very deep, large models, and it is obvious you need the largest batch size possible).\n",
"* For comparing multiple hyperparameter configurations, you can add them to TensorBoard. This is a clean way of comparing multiple runs. If interested, a blog on this can be found [here](https://towardsdatascience.com/a-complete-guide-to-using-tensorboard-with-pytorch-53cb2301e8c3).\n",
"* There are multiple libraries that support you in automatic hyperparameter search. A good overview for those in PyTorch can be found [here](https://medium.com/pytorch/accelerate-your-hyperparameter-optimization-with-pytorchs-ecosystem-tools-bc17001b9a49).\n",
"\n",
Expand All @@ -87,8 +87,8 @@
"* The learning rate is an important parameter, which depends on the optimizer, the model, and many more other hyperparameters.\n",
"* A usual good starting point is 0.1 for SGD, and 1e-3 for Adam.\n",
"* The deeper the model is, the lower the learning rate usually should be. For instance, Transformer models usually apply learning rates of 1e-5 to 1e-4 for Adam.\n",
"* The lower your batch, the lower the learning rate should be. Consider using [gradient accumulation](https://towardsdatascience.com/what-is-gradient-accumulation-in-deep-learning-ec034122cfa) if your batch size is getting too small (PyTorch Lightning supports this, see [here](https://pytorch-lightning.readthedocs.io/en/latest/training_tricks.html#accumulate-gradients)). \n",
"* Consider using the PyTorch Lightning [learning rate finder](https://pytorch-lightning.readthedocs.io/en/latest/lr_finder.html) toolkit for an initial good guess. \n",
"* The lower your batch, the lower the learning rate should be. Consider using [gradient accumulation](https://towardsdatascience.com/what-is-gradient-accumulation-in-deep-learning-ec034122cfa) if your batch size is getting too small (PyTorch Lightning supports this, see [here](https://pytorch-lightning.readthedocs.io/en/latest/advanced/training_tricks.html#accumulate-gradients)). \n",
"* Consider using the PyTorch Lightning [learning rate finder](https://pytorch-lightning.readthedocs.io/en/latest/advanced/training_tricks.html?highlight=Learning%20rate%20finder#learning-rate-finder) toolkit for an initial good guess. \n",
"\n",
"#### LR scheduler\n",
"\n",
Expand Down Expand Up @@ -117,7 +117,7 @@
"\n",
"### Grid search with SLURM \n",
"\n",
"* SLURM supports you to do a grid search with [job arrays](https://help.rc.ufl.edu/doc/SLURM_Job_Arrays). We have discussed job arrays in the [Lisa guide](https://uvadlc-notebooks.readthedocs.io/en/latest/tutorial_notebooks/tutorial1/Lisa_Cluster.html#Job-Arrays).\n",
"* SLURM supports you to do a grid search with [job arrays](https://help.rc.ufl.edu/doc/SLURM_Job_Arrays). We have discussed job arrays in the [Lisa guide](https://uvadlc-notebooks.readthedocs.io/en/latest/common/tutorial_notebooks/tutorial1/Lisa_Cluster.html#Job-Arrays).\n",
"* Job arrays allow you to start N jobs in parallel, each running with slightly different settings.\n",
"* It is effectively the same as creating N job files and calling N times `sbatch ...`, but this can become annoying and is messy at some point."
]
Expand All @@ -128,7 +128,7 @@
"source": [
"#### PyTorch Lightning\n",
"\n",
"Writing the job arrays can be sometimes annoying, and hence it is adviced to write a script that can automatically generate the hyperparameter files if you have to do this often enough (for instance, by adding the seed parameter 4 times to each other hyperparam config). However, if you are using PyTorch Lightning, you can directly create a job array file. The documentation for this can be found [here](https://pytorch-lightning.readthedocs.io/en/latest/slurm.html#building-slurm-scripts)."
"Writing the job arrays can be sometimes annoying, and hence it is adviced to write a script that can automatically generate the hyperparameter files if you have to do this often enough (for instance, by adding the seed parameter 4 times to each other hyperparam config). However, if you are using PyTorch Lightning, you can directly create a job array file. The documentation for this can be found [here](https://pytorch-lightning.readthedocs.io/en/latest/common/slurm.html#building-slurm-scripts)."
]
},
{
Expand Down

0 comments on commit 251194e

Please sign in to comment.