0
0
PyTorchml~5 mins

Dropout (nn.Dropout) in PyTorch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of Dropout in neural networks?
Dropout helps prevent overfitting by randomly turning off some neurons during training. This forces the network to learn more robust features.
Click to reveal answer
beginner
How does nn.Dropout behave differently during training and evaluation in PyTorch?
During training, nn.Dropout randomly sets some inputs to zero. During evaluation, it passes all inputs unchanged to keep the full signal.
Click to reveal answer
beginner
What does the parameter 'p' in nn.Dropout(p) represent?
The parameter 'p' is the probability of an element being zeroed (dropped) during training. For example, p=0.3 means 30% of neurons are dropped randomly.
Click to reveal answer
intermediate
Show a simple PyTorch example of applying nn.Dropout with p=0.5 to a tensor.
import torch
import torch.nn as nn

x = torch.ones(5)
dropout = nn.Dropout(p=0.5)
dropout.train()  # set to training mode
output = dropout(x)
print(output)

# Output will have about half the elements set to zero randomly.
Click to reveal answer
beginner
Why is Dropout usually turned off during model evaluation?
Dropout is turned off during evaluation to use the full network capacity for predictions. Turning it off ensures stable and consistent outputs.
Click to reveal answer
What does nn.Dropout(p=0.2) do during training?
ARandomly sets 20% of inputs to zero
BRandomly sets 80% of inputs to zero
CScales inputs by 0.2
DDoes nothing
During evaluation, nn.Dropout in PyTorch:
ARandomly drops neurons
BScales outputs by dropout probability
CRaises an error
DPasses inputs unchanged
Why use Dropout in training a neural network?
ATo speed up training
BTo increase model size
CTo prevent overfitting
DTo reduce input size
If you set nn.Dropout(p=0), what happens?
AAll neurons are dropped
BNo neurons are dropped
CHalf neurons are dropped
DError occurs
Which mode must be set for nn.Dropout to actually drop neurons?
Atrain()
Beval()
Ctest()
Ddropout()
Explain how nn.Dropout works and why it is useful in training neural networks.
Think about how turning off some neurons helps the network learn better.
You got /4 concepts.
    Describe the difference in behavior of nn.Dropout during training and evaluation phases.
    Consider what happens to the inputs in each phase.
    You got /3 concepts.