Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytorch lr_scheduler problem #2

Closed
gshuangchun opened this issue May 6, 2022 · 3 comments
Closed

pytorch lr_scheduler problem #2

gshuangchun opened this issue May 6, 2022 · 3 comments

Comments

@gshuangchun
Copy link

Hi, I have this error below. Could you please help me?

Traceback (most recent call last):
File "/home/shuangchun/Code/Triplet 2022/rendezvous/pytorch/run.py", line 460, in
[float(f'{sch.get_last_lr()[0]:.6f}') for sch in lr_schedulers], [float(f'{v:.6f}') for v in wp_lr], warmups, power,
File "/home/shuangchun/Code/Triplet 2022/rendezvous/pytorch/run.py", line 460, in
[float(f'{sch.get_last_lr()[0]:.6f}') for sch in lr_schedulers], [float(f'{v:.6f}') for v in wp_lr], warmups, power,
File "/home/shuangchun/anaconda3/envs/P7t10/lib/python3.7/site-packages/torch/optim/lr_scheduler.py", line 99, in get_last_lr
return self._last_lr
AttributeError: 'SequentialLR' object has no attribute '_last_lr'

@nwoyecid
Copy link
Member

nwoyecid commented May 7, 2022

Please provide your torch and torchvision version.

@gshuangchun
Copy link
Author

Pyorch = 1.10.1
TorchVision = 0.11.2

@gshuangchun
Copy link
Author

gshuangchun commented May 7, 2022

Thank you for your attention. I have solved this problem by replacing:

[float(f'{sch.get_last_lr()[0]:.6f}') for sch in lr_schedulers], [float(f'{v:.6f}') for v in wp_lr], warmups, power,
to

header3 = "** LR Config: Init: {} | Peak: {} | Warmup Epoch: {} | Rise: {} | Decay {} | train params {} | all params {} **".format(
    [float(f"{op.state_dict()['param_groups'][0]['lr']:.6f}") for op in optimizers], [float(f'{v:.6f}') for v in wp_lr],
    warmups, power,
    decay_rate, pytorch_train_params, pytorch_total_params)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants