When it comes to neural networks, one of the most important set terms is the learning rate. This term refers to how quickly the network learns as it trains. If you increase this value too much, the network will overshoot its target and not converge; if you decrease it too much, the *network may even get stuck* in a local minimum!

The default setting for the learning rate is usually very small. Starting off with a **low learning rate helps** the network learn more slowly, giving it time to adjust to changes. As the article says, however, there are times when increasing the learning rate can **help achieve better results**.

This article will discuss some conditions under which raising the learning rate is appropriate. We will also go into detail about what **settings work best** in these situations.

## Comparing different learning rates

When it comes to optimizing neural networks, one of the most important settings is the learning rate. This parameter controls how quickly your network learns as well as whether or not it gets stuck during training.

If the learning rate is too low, the network will struggle to **find good local optima** and may even get “stuck” at a *bad local minimum*. This **could cause poor test accuracy** and failing to converge!

On the other hand, if the learning rate is too high then the network will over-fit the data which usually results in poorer performance.

This article will discuss some helpful tips for determining appropriate values of the learning rate for your deep learning model.

## Understanding how to choose a learning rate

When it comes to choosing your learning rate, there are *two main factors* that determine whether or not your neural network training will succeed. The first is when you decrease the learning rate, more iterations can be needed to reach convergence.

The second is what kind of result you want to achieve. If you would like your model to learn certain concepts over others, then lowering the learning rate may not work as well because fewer gradient steps are **taken towards achieving** this goal.

If however you only care about **obtaining good overall results**, then lower the learning rate! You may need to train for longer than necessary, but your overall performance will improve much more due to the reduced noise.

There are several strategies for **setting different types** of learning rates depending on what task you are trying to accomplish. This article will go into more detail about them.

## Trial and error approach to choosing a learning rate

Choosing your learning rate is one of the most important things you will do when training neural networks! There are two main strategies for doing this.

One is called the batch-based method, where you *test different values* of the learning rate until you find an optimal value. This *typically means trying several times* to train a model with a given amount of time, or using a budgeted number of iterations and testing at every few hundred steps how close you can get.

The other strategy is called the stochastic gradient descent (SGD) method, where instead of **trying many different learning rates**, you only try one at a time and then use that knowledge to *help choose new ones*.

This article will go more into detail about these methods and some reasons why one may be better than the other.

## Standard learning rates

A very common setting for neural networks is using an [*optimization function*]{} to decrease the cost, or performance measure of the network. An optimization function can be determined by the loss (to make the network perform worse), accuracy (to improve the quality of the classifier), or another metric such as valence (to determine whether the output is positive or negative).

By taking a look at the gradient of the optimization function with respect to each weight, we are able to find optimal values for these weights. By doing this many times, you get different sets of optimal weights!

This process is called [*gradient descent*]{}. The most commonly used form of gradient descent is [*Stochastic Gradient Descent*]{}, which uses random fluctuations to decide how much to reduce the parameter value. This allows the algorithm to move forward more quickly because it does not have to wait for every iteration to update all of the parameters.

However, if there is no change after several iterations, then the algorithm will sometimes “freeze” and do nothing for some time before moving on. This happens when the parameter value is already close to its limit. To prevent this, we need to increase the [*learning rate*]{}- the amount of change per unit time that the algorithm performs.

When training deep neural nets, people often use [*adam optimizers*]{} to perform stochatic gradient descent.

## Polynomial decay

The other **common learning rate scheme** is called polynomial decay or cosine decay. This is done by multiplying the learning ratio with time, creating an exponential drop-off.

The easiest way to think about this is like someone who is *constantly losing weight —* you need to eat less to lose fat, and the easier you can stick to that, the faster you will lose weight. With polynomial decay, the longer it takes for the model to be trained, the slower the drop off of the learning ratio.

This has the opposite effect as *linear decay —* the harder you work, the quicker your brain gets better at solving problems. By having both approaches in place, deep neural networks are able to find a good balance between getting improved quickly and staying improved even after training is over!

There are some drawbacks to **using polynomial decay though**. Because the ratio drops more slowly, there may not be as strong a reduction in performance when training is finished.

## Gaussian decay

The other major element of your loss function is what’s called the learning rate or step size. This sets how quickly the network learns and adjusts its model.

Usually, deep neural networks are trained using an optimization algorithm known as stochastic gradient descent (SGD). SGD works by **taking small steps towards** our target value, which means it can get stuck in local minima for long periods of time.

When this happens, the network will lose faith in itself and become less efficient at solving problems. To prevent this, we need to make changes to the learning rate so that it keeps moving!

One way to do this is **use something called exponential decay**. Exponential decay decreases the learning rate over time. You can choose any length of time depending on how much training you have done and how fast the net is getting there already.

The classic example of exponential decayed is when you pour water from a tall bottle. It takes longer for the water to run out the bottom than up the side. In those cases, the faster the liquid drops, the more slowly it will drop off.

That analogy applies here well to intuition of why decreasing the learning rate slows down the progress of the network. By reducing the speed at which the parameters are changing, the system has to work harder to reach the same result, thus requiring more iterations to converge.

There are many ways to **implement exponential decay** in TensorFlow.