Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[MXNET-593] Adding 2 tutorials on Learning Rate Schedules #11296

Merged
merged 5 commits into from
Jun 26, 2018

Conversation

thomelane
Copy link
Contributor

Description

First tutorial is on learning rate schedules in mxnet.lr_scheduler, how to use them with Optimizer and Trainer in Gluon and how to implement a custom learning rate schedule. Contains visualizations of the schedules.

Second tutorial shows how to use common learning rate schedules such as Cyclical schedules, SDG with Restarts, Warm-up and Cool-down. Many paper references are provided. Contains visualizations of the schedules.

Added to tutorial testing and index page.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http:https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@thomelane thomelane requested a review from szha as a code owner June 15, 2018 00:12
@mklissa
Copy link

mklissa commented Jun 15, 2018

Very informative and well-written! Good job!

Copy link
Contributor

@KellenSunderland KellenSunderland left a comment

Choose a reason for hiding this comment

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

Some minor comments. Great tutorial as usual @thomelane.


# Learning Rate Schedules

Setting the learning rate for stochastic gradient descent (SGD) is crucially important when training neural network because it controls both the speed of convergence and the ultimate performance of the network. One of the simplest learning rate strategies is to have a fixed learning rate throughout the training process. Choosing a small learning rate allows the optimizer find good solutions but this comes at the expense of limiting the initial speed of convergence. Changing the learning rate over time can overcome this tradeoff.
Copy link
Contributor

Choose a reason for hiding this comment

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

"when training neural network" -> "when training neural networks"

Copy link
Contributor

Choose a reason for hiding this comment

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

"good solutions but this" -> "good solutions, but this"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected.


def __call__(self, iteration):
if iteration <= self.cycle_length:
unit_cycle = (1 + math.cos(iteration*math.pi/self.cycle_length))/2
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could add spaces around * and / operators to be consistent (and pass some linters).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected throughout.


Epoch: 8; Batch 0; Loss 0.039928; LR 0.000300 <!--notebook-skip-line-->

Epoch: 9; Batch 0; Loss 0.003349; LR 0.000300 <!--notebook-skip-line-->
Copy link
Contributor

Choose a reason for hiding this comment

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

Epoch: 9; Batch 0; Loss 0.003349; LR 0.000300 should be Epoch: 9; Batch 0; Loss 0.003349; LR 0.0000300
I think right? (i.e. there's a missing 0 in LR).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch! Was due to schedule changing after defined step, not before, essentially expecting the iteration counter to start at 1 rather than 0. Corrected this error and clarified throughout.

self.inc_fraction = inc_fraction

def __call__(self, iteration):
if iteration <= self.cycle_length*self.inc_fraction:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: again I would be consistent and alway have a space in between operators *, /, etc.
Same comment for code below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed throughout.


#### 1-Cycle: for "Super-Convergence"

Cool-down is used in the "1-Cycle" schedule proposed by [Leslie N. Smith, Nicholay Topin (2017)](https://arxiv.org/abs/1708.07120) to train neural networks very quickly in certain circumstances (coined "super-convergence"). We implement a single and symmetric cycle of the triangular schedule above (i.e. `inc_fraction=0.5`), followed by a cool-down period of `cooldown_length` iterations.
Copy link
Contributor

Choose a reason for hiding this comment

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

Super-convergence is also introduced in the previous section's description. Seems a bit redundant here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, removed.

@thomelane
Copy link
Contributor Author

@KellenSunderland thanks for the review and feedback! Made changes as suggested, and fixed off by one.

@thomelane
Copy link
Contributor Author

@indhub believe this is good to merge, since made adjustments as per @KellenSunderland feedback.

@thomelane thomelane changed the title Adding 2 tutorials on Learning Rate Schedules [MXNET-593] Adding 2 tutorials on Learning Rate Schedules Jun 26, 2018
@thomelane
Copy link
Contributor Author

@indhub indhub merged commit e494cee into apache:master Jun 26, 2018
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
* Added two tutorials on learning rate schedules; basic and advanced.

* Correcting notebook skip line.

* Corrected cosine graph

* Changes based on @KellenSunderland feedback.
@thomelane thomelane deleted the tutorials_lr_sched branch January 11, 2019 19:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants