liveBook · Manning

Dropout

As explained in Natural Language Processing in Action, Second Edition

A dropout layer is a neural-network layer that randomly disables units during training to reduce reliance on particular internal representations.

Dropout is a neural-network regularization technique that randomly hides neuron outputs during training. By silencing some pathways, it prevents a model from relying too heavily on particular words, patterns, or filters. section 7.4.4

In a text CNN, place dropout near the end, before the fully connected prediction layer. Hiding pooled pattern features forces the classifier to diversify its learned evidence and improves robustness to unusual language. section 7.4.4

Tune dropout as a practical hyperparameter:

  • Try ratios around 30%–50% for many neural networks, while keeping single-layer CNN ratios at or below about 20%. section 7.5.5
  • Increase dropout when the model overfits and simplifying the architecture is not suitable. section 8.4.4
  • Avoid setting the percentage much above 50%: learning can slow and validation error may become unstable. section 8.4.4
  • Record each experiment with its architecture, learning rate, dropout, training time, and test loss before choosing the next adjustment. section 8.4.4
import pandas as pd
import jsonlines

with jsonlines.open('experiments.jsonl') as fin:
    lines = list(fin)
df = pd.DataFrame(lines)
df.to_csv('experiments.csv')
cols = 'rnn_type epochs lr num_layers dropout epoch_time test_loss'
cols = cols.split()
df[cols].round(2).sort_values('test_loss').head(10)epochs   lr  num_layers  dropout  epoch_time  test_loss
37      12  2.0           2      0.2       35.43       5.23
28      12  2.0           1      0.0       22.66       5.23
49      32  0.5           2      0.0       32.35       5.22
57      32  0.5           2      0.2       35.50       5.22
38      12  2.0           3      0.2       46.14       5.21
50      32  0.5           3      0.0       37.36       5.20
52      32  2.0           1      0.0       22.90       5.10
55      32  2.0           5      0.0       56.23       5.09
53      32  2.0           2      0.0       32.49       5.06
54      32  2.0           3      0.0       38.78       5.04

Compare RNN experiments by dropout, layer count, learning rate, training time, and test loss. section 8.4.4

How Natural Language Processing in Action, Second Edition covers it

How deep it goes
Explains training intuition, CNN placement, ratio selection, and tuning effects, but does not detail implementation internals.
Examples
Uses text CNNs, RNN language models, tweet classification, learning curves, and recorded hyperparameter experiments.
What it assumes
Assumes familiarity with neural networks, CNNs or RNNs, training data, validation error, and hyperparameters.
What you can do after
Apply dropout via a neural-network layer and tune its percentage to control overfitting in NLP models.
How it connects
Connects dropout with neural networks, convolutional neural networks, recurrent neural networks, pooling, overfitting, regularization, and hyperparameter tuning.

Also explained in

Compare how 12 books explain dropout →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Natural Language Processing in Action, Second Edition. The section links point to the parts of the book it draws on.