調整學習率-torch.optim.lr_scheduler.MultiStepLR()方法


 
        
optimizerG = optim.Adam(netG.parameters(), lr=opt.lr_g, betas=(opt.beta1, 0.999))
torch.optim.lr_scheduler.MultiStepLR(optimizer=optimizerG,milestones=[1600],gamma=opt.gamma)

torch.optim.lr_scheduler.MultiStepLR(optimizer, milestones, gamma=0.1, last_epoch=-1)
milestones為一個數組,如 [50,70]. gamma為倍數。如果learning rate開始為0.01 ,則當epoch為50時變為0.001,epoch 為70 時變為0.0001。
當last_epoch=-1,設定為初始lr。

參考博客:

https://blog.csdn.net/qq_41872630/article/details/86749972


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM