davidtvs / pytorch-lr-finder

A learning rate range test implementation in PyTorch
MIT License
921 stars 120 forks source link

how to get the best LR #84

Open ardeal opened 2 years ago

ardeal commented 2 years ago

Hi, I run the following code and got the following picture. I am wondering what the best LR is in my picture? how to print/display the best LR in the code?


      finding_lr = lr_finder.LRFinder(net.model, optimizer, criterion, device="cpu")

        finding_lr.range_test(train_loader, start_lr=0.0001, end_lr=0.1, num_iter=1000, step_mode="exp")

        finding_lr.plot(savefig_path=os.path.join(args.output_dir, 'lr_finder.png'))

image

NaleRaphael commented 2 years ago

Hi @ardeal,

You can get a suggested learning rate by passing argument suggest_lr to lr_finder.plot(), it will return an axis of plot and a suggested lr.

ardeal commented 2 years ago

@NaleRaphael , You argument suggest_lr works. Thanks!