liveBook · Manning

Dropout

As explained in Distributed Machine Learning Patterns

A neural-network layer that randomly omits units during training to reduce overfitting and model complexity.

Dropout is a neural-network layer that randomly removes hidden units during training. It reduces overfitting, limits model complexity, and can speed computation. section 9.2.1 section 8.1.1

Implement dropout as a model-architecture choice:

  • Insert a Dropout layer alongside dense or other neural-network layers. section 8.1.1
  • Set a rate such as 0.2, or drop half of the hidden units in a model variation. section 9.2.1 section 8.1.1
  • Compare its training behavior and accuracy with a basic model or a batch-normalized variation. section 9.2.1

MNIST classifier

A TensorFlow Keras sequential model flattens 28 × 28 handwritten-digit images, applies a dense ReLU layer, inserts Dropout(0.2), and predicts ten classes with softmax. section 8.1.1

Listing 9.4 Defining the basic CNN model
def build_and_compile_cnn_model():
 print("Training CNN model")
 model = models.Sequential()
 model.add(layers.Input(shape=(28, 28, 1), name='image_bytes'))
 model.add(
         layers.Conv2D(32, (3, 3), activation='relu'))
 model.add(layers.MaxPooling2D((2, 2)))
 model.add(layers.Conv2D(64, (3, 3), activation='relu'))
 model.add(layers.MaxPooling2D((2, 2)))
 model.add(layers.Conv2D(64, (3, 3), activation='relu'))
 model.add(layers.Flatten())
 model.add(layers.Dense(64, activation='relu'))
 model.add(layers.Dense(10, activation='softmax'))
 model.summary()
 model.compile(optimizer='adam',
          loss='sparse_categorical_crossentropy',
          metrics=['accuracy'])
 return model

Inspect the surrounding TensorFlow Keras CNN definition to see where a dropout variation fits within convolutional, pooling, flattening, and dense layers. section 9.2.1

How Distributed Machine Learning Patterns covers it

How deep it goes
Defines the layer’s purpose, placement, and example rates without explaining its internal mathematical mechanism.
Examples
Uses MNIST digit classification and a CNN variation that drops half of its hidden units.
What it assumes
Assumes familiarity with basic neural-network layers and model training while demonstrating the technique in a simple classifier.
What you can do after
Apply it via TensorFlow Keras by inserting and configuring a Dropout layer in a sequential model.
How it connects
Connects dropout with neural networks, convolutional neural networks, batch normalization, overfitting, and model generalization.

Also explained in

Compare how 12 books explain dropout →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Distributed Machine Learning Patterns. The section links point to the parts of the book it draws on.