Created
December 4, 2020 10:39
-
-
Save hccho2/3536a97021b0aad027f5f0342097971c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lr = 0.1 | |
model = nn.Linear(10,1) | |
optimizer = torch.optim.Adam(model.parameters(), lr=lr) | |
lambda1 = lambda epoch: epoch/10 # lr * lambda1(epoch+1) | |
scheduler = torch.optim.lr_scheduler.LambdaLR(optimizer,lambda1) | |
print(optimizer.state_dict()) | |
for epoch in range(5): | |
optimizer.step() | |
scheduler.step() | |
print(epoch, lr * (epoch+1)/10 , optimizer.state_dict()['param_groups'][0]['lr']) # optimizer.state_dict()['param_groups']가 길이 1짜리 list | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.