TL;DR
A reinforcement-learning agent has to try things it does not yet know are good. A noisy network handles this by adding random noise to its own weights, with a learned amount of noise for each weight, so the network's output varies from one step to the next. The agent then acts greedily on the noisy output, and the randomness in the network does the exploring. The network learns how big the noise should be, so it explores more where it is unsure and less where it has learned.
Builds on: Deep Q-Network, Gaussian (Normal) Distribution · Leads to: Rainbow, which combines it with other improvements to DQN
Where it's used
Atari games with sparse rewards. In games such as Montezuma's Revenge, the agent must perform a long sequence of correct actions before it gets any reward. A common fix, the Epsilon-Greedy Policy, picks a random action with a fixed probability. That random action is unlikely to continue a useful sequence, so the agent rarely gets far. Noisy networks were introduced to fix this by making exploration part of the value network, and they gave clear gains on hard Atari games.
Rainbow. The Rainbow agent of 2017 combined six improvements to DQN, and noisy networks replaced its epsilon-greedy exploration. The combined agent was far stronger across the Atari suite than any single improvement, which is why noisy layers now appear in many reinforcement-learning codebases.
Any problem with a learned value function that needs exploration. The same layer can sit in a policy head or a value head. Anywhere a network must choose actions and must keep learning about options it has not tried much, a noisy final layer provides exploration without a separate schedule to tune.
How it works
Take a single neuron with one input and one weight, and trace what the noise does. Let the usual weight be , the noise scale be , and the input be .
- Write the weight as a mean plus a noisy part. The noisy weight is , where is a random number drawn from a standard normal distribution (mean 0, variance 1). The network stores and as trainable parameters. Check: with the weight is just .
- Draw a fresh noise sample. Suppose the draw is . The weight is . Check: this is above the mean, as expected for a positive draw.
- Compute the output. The output is . Check: the mean output is , so the noise moved the output by .
- Draw again and see the other side. With the weight is and the output is . The noise moved the output by this time.
- Learn the scale. During training, backpropagation sends the gradient into and into just as for any weight, using stochastic gradient descent. If the noise hurts the loss, shrinks. If the noise helps the agent find better actions, can grow. The agent therefore decides how much to explore.
- Act greedily on the noisy values. In a state, the network gives a Q value for each action. A Q value is the network's estimate of the total future reward for taking that action in that state. The agent takes the action with the largest noisy value, which is called acting greedily. Because the noise changes from step to step, the choice changes too, and that is the exploration.
- Use the means when evaluating. After training, the noise can be switched off so that the agent plays with its best estimates, the means . This is the usual practice, and it avoids playing with randomness when the goal is the best score.
flowchart LR P[means mu and scales sigma] --> N[draw noise epsilon] N --> W[noisy weights mu plus sigma times epsilon] W --> Q[Q values for each action] Q --> A[take the greedy action] A --> L[loss gradient updates mu and sigma] L --> P
The loop shows the important point: the noise is part of the function being trained, so the gradient can change how much noise there is.
The math
The paper's noisy linear layer computes . Here means element-by-element multiplication, is the layer's input vector, and are matrices of the same shape as the weights, and and are vectors for the bias. The random matrix and the random vector are the noise.
Step 2 in symbols: the noisy weights
Each weight is , where is drawn from a standard normal distribution. The mean is the centre of the distribution of possible weights, and is its spread. Because the spread is learned, the layer has a learned degree of randomness.
Step 3 in symbols: the output
Multiply the noisy matrix by the input vector and add the noisy bias. The output for neuron is
In the one-weight example, . With this gives , as in Step 3 of How it works.
Step 5 in symbols: learning the scale
Let be the loss, here the DQN loss with the noisy network's Q values, where stands for all the and . The chain rule gives
so the change to the spread depends on the gradient of the weight and on the sign and size of the noise draw. The mean is learned with .
Noise with fewer random numbers
Drawing an independent normal number for every weight is costly for big layers. The paper's factorised form draws one number per input and one per output, and builds the weight noise from them. Let , let be a draw per input and a draw per output, and set
For a layer with inputs and outputs this needs draws, not . The function keeps the noise from being too small when the draws are near zero.
Worked examples
Take , , and no bias.
- The noisy weight is .
- Draw . Then and . This is the mean output.
- Draw . Then and .
- Draw . Then and .
- Interpretation: each unit of noise moves the output by in one direction or the other. The mean sits between the two outcomes, and the noise is symmetric around it.
A state has one input feature . Two actions each have a single weight, with these learned values:
- Left: , .
- Right: , .
- With the noise switched off, the means give and . The greedy action is left.
- Draw a sample with and . Then and . The greedy action is right.
- Draw a second sample with and . Then and . The greedy action is left again.
- Interpretation: the action with the larger uncertainty, left with , is tried more often, while right with is almost always its mean value. The agent explores in proportion to what it does not know. A fixed epsilon rule would pick random actions regardless of how uncertain each one is.
A small output layer maps a 2-number input to 2 outputs. The layer has , , and everywhere. The input is . The noise draws are for the two inputs and for the two outputs.
- Compute the input factors: and .
- Compute the output factors: and .
- Build the weight noise, . Row 1 (factor ) is . Row 2 (factor ) is .
- Build the noisy weights, . Row 1 is . Row 2 is .
- Build the noisy bias, , which is .
- Compute the outputs. Output 1 is . Output 2 is .
- Interpretation: the sampled outputs are and the means give . Here the noise is large compared with the means, so the sample is far from the mean. The agent would act greedily on and choose output 2 for this sample.
Try it: with the noise switched off at evaluation, what are the two outputs for ?
Answer: . With the means alone, output 1 is , and output 2 is . The agent would then choose output 2, the same as the noisy sample, but for a different reason.
Common mistakes and tradeoffs
It is tempting to think a noisy network is just a network with dropout. In fact dropout switches neurons off at random to regularise, while the noise here is a learned scale on the weights, and the gradient controls it. The goal is exploration rather than preventing overfitting.
It is tempting to think the noise is the same as epsilon-greedy with a smaller number. In fact epsilon-greedy picks a random action with a fixed chance that never adapts. A noisy network's exploration depends on the state, because is learned and the spread of Q values depends on the input. Where the agent is sure, it explores little; where it is not sure, it explores more.
It is tempting to think the noise is resampled only once per episode. In practice it is resampled often, typically each step or each training update, because a noise draw that is held fixed for a long time gives correlated behaviour and loses the benefit.
It is tempting to think the noise should stay on at evaluation. In fact the usual practice is to use the means, so the reported score reflects the learned values rather than a random draw.
Use noisy networks when exploration is the bottleneck, especially with sparse rewards, and when you can afford roughly twice the parameters in the noisy layers, since each has a mean and a scale. Do not use them when a simple policy already explores enough, or when the network is small and epsilon-greedy is cheap and effective. Alternatives include entropy bonuses (see Maximum Entropy Reinforcement Learning), count-based bonuses, and curiosity signals.
History
Before 2017, the standard exploration in deep reinforcement learning was epsilon-greedy, used in the original DQN work. Its weakness on hard exploration problems was well known, and the common response was to add intrinsic rewards or to tune the schedule by hand.
Fortunato and colleagues proposed noisy networks in 2017, putting learned noise directly into the network weights and showing that it improved exploration on Atari games compared with epsilon-greedy. The factorised form was introduced to make the noise cheap to draw for large layers.
Later in 2017, the Rainbow paper combined noisy networks with several other DQN improvements and reported a combined agent that was stronger on the Atari suite than the parts alone. That combination made noisy layers a standard component in later value-based agents.
Recap
- Exploration can come from the network itself: each weight is a learned mean plus learned noise.
- Each step draws new noise, so the greedy action changes, and the gradient learns how large the noise should be.
- The noisy layer replaces epsilon-greedy, and its exploration depends on the state and on what the agent is unsure about.
- The factorised form needs only one draw per input and output, which keeps large layers cheap.
- Next, read the Rainbow paper to see noisy networks combined with other DQN improvements.