Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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'

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading