davidtvs / pytorch-lr-finder

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

'<' not supported between instances of 'MSELoss' and 'int' #83

Closed RowanG1 closed 9 months ago

RowanG1 commented 2 years ago

Using: lr_finder = LRFinder(model, optimizer, loss_fn) Get this error: '<' not supported between instances of 'MSELoss' and 'int'

/usr/local/lib/python3.7/dist-packages/fastai/callback/schedule.py in init(self, start_lr, end_lr, num_it, stop_div) 169 "Training with exponentially growing learning rate" 170 def init(self, start_lr=1e-7, end_lr=10, num_it=100, stop_div=True): --> 171 if num_it < 6: num_it = 6 172 self.scheds = {'lr': [SchedExp(s, e) for (s,e) in zip(start_lr,end_lr) 173 ] if is_listy(start_lr) else SchedExp(start_lr, end_lr)}

Any ideas?

NaleRaphael commented 2 years ago

Hi @RowanG1,

Currently provided trackback message is not complete and it shows only code related to the callback from fastai library, could you provide further more information about it?

And if I understand correctly, I'm afraid that you are using the wrong LRFinder. According to given message, the code in trackback message is exactly from fastai library.

That is, the invocation of LRFinder is for this library torch_lr_finder instead of the one in fastai library, but the LRFinder you imported is from fastai library. Therefore, it took the 3rd argument as num_it.

RowanG1 commented 2 years ago

Brilliant, thanks. I updated as follows: from torch_lr_finder import LRFinder as PytorchLRFinder