Complete the code to set the learning rate for the optimizer.
optimizer = torch.optim.SGD(model.parameters(), lr=[1])The learning rate must be a positive float. 0.01 is a common starting value.
Complete the code to reduce the learning rate by a factor of 10.
new_lr = old_lr [1] 10
Dividing the old learning rate by 10 reduces it by a factor of 10.
Fix the error in the learning rate scheduler code.
scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=5, gamma=[1])
The gamma parameter must be a positive number less than 1 to reduce the learning rate.
Fill both blanks to create a dictionary of learning rates for different layers.
lr_dict = {'conv': [1], 'fc': [2]Typically, convolutional layers use a smaller learning rate (0.001) and fully connected layers a larger one (0.01).
Fill all three blanks to create a learning rate scheduler with warmup and decay.
scheduler = torch.optim.lr_scheduler.LambdaLR(optimizer, lr_lambda=lambda epoch: [1] if epoch < 5 else [2] ** (epoch - 5) * [3])
This code linearly increases learning rate during warmup (epoch/5), then decays it by 0.9 power times 1.