Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'torch.optim.lr_scheduler' has no attribute 'LinearLR'

I'm trying to train my own object detection model with Pytorch. But im getting always this error. I tried to change the torch version but this doesn't helped.
My packages: torchvision-0.11.1 and torch-1.10.0

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-9e52b782b448> in <module>()
      4 for epoch in range(num_epochs):
      5     # training for one epoch
----> 6     train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq=10)
      7     # update the learning rate
      8     lr_scheduler.step()

/content/engine.py in train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq)
     21         warmup_iters = min(1000, len(data_loader) - 1)
     22 
---> 23         lr_scheduler = torch.optim.lr_scheduler.LinearLR(
     24             optimizer, start_factor=warmup_factor, total_iters=warmup_iters
     25         )

AttributeError: module 'torch.optim.lr_scheduler' has no attribute 'LinearLR'
like image 446
Mao76 Avatar asked Oct 27 '25 14:10

Mao76


1 Answers

LinearLR scheduler was only recently introduced (v1.10.0). Please make sure your pytorch version is up to date and try again.

like image 154
Shai Avatar answered Oct 29 '25 02:10

Shai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!