Recall & Review
beginner
What is the purpose of the CosineAnnealingLR scheduler in PyTorch?
CosineAnnealingLR adjusts the learning rate following a cosine curve, gradually decreasing it to a minimum value to help the model converge better during training.
Click to reveal answer
beginner
How does the learning rate change over time with CosineAnnealingLR?
The learning rate starts at the initial value and decreases following a half cosine wave until it reaches the minimum learning rate at the end of the cycle.
Click to reveal answer
intermediate
What are the key parameters of CosineAnnealingLR in PyTorch?
The key parameters are 'optimizer' (the optimizer to adjust), 'T_max' (the number of iterations for one cycle), and 'eta_min' (the minimum learning rate).
Click to reveal answer
intermediate
Why might you choose CosineAnnealingLR over a constant learning rate?
Because it helps the model avoid getting stuck in bad local minima by reducing the learning rate smoothly, which can improve training stability and final accuracy.
Click to reveal answer
beginner
Show a simple PyTorch code snippet to create a CosineAnnealingLR scheduler.
import torch.optim as optim
optimizer = optim.SGD(model.parameters(), lr=0.1)
scheduler = optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=10, eta_min=0.001)
for epoch in range(10):
train()
scheduler.step()Click to reveal answer
What does the 'T_max' parameter in CosineAnnealingLR represent?
✗ Incorrect
'T_max' sets how many iterations or epochs the scheduler takes to complete one cosine annealing cycle.
What happens to the learning rate at the end of the CosineAnnealingLR cycle?
✗ Incorrect
At the end of the cycle, the learning rate reaches the minimum value specified by 'eta_min'.
Which optimizer can CosineAnnealingLR be used with?
✗ Incorrect
CosineAnnealingLR works with any PyTorch optimizer passed to it.
Why is cosine annealing beneficial for training neural networks?
✗ Incorrect
Cosine annealing smoothly decreases the learning rate, helping training stability and convergence.
What is the default value of 'eta_min' in CosineAnnealingLR if not specified?
✗ Incorrect
By default, 'eta_min' is 0.0, meaning the learning rate can anneal down to zero.
Explain how the CosineAnnealingLR scheduler adjusts the learning rate during training.
Think about how the learning rate changes smoothly over time.
You got /4 concepts.
Describe a simple PyTorch training loop using CosineAnnealingLR.
Focus on where the scheduler fits in the training process.
You got /4 concepts.