pytorch - 💡(How to fix) Fix Adadelta uses SGD in its examples

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Code Example

optim = torch.optim.SGD(model.parameters(), lr=3e-4)

---

model = torch.nn.Linear(10, 10)

optim = torch.optim.Adadelta(
    model.parameters(),
    lr=1.0,      # default LR
    rho=0.9,
    eps=1e-6,
)

scheduler1 = torch.optim.lr_scheduler.LinearLR(
    optim,
    start_factor=0.1,
    end_factor=1,
    total_iters=20,
)

scheduler2 = torch.optim.lr_scheduler.CosineAnnealingLR(
    optim,
    T_max=80,
    eta_min=0.01,   # scaled for Adadelta-style LR
)

lr = torch.optim.lr_scheduler.SequentialLR(
    optim,
    schedulers=[scheduler1, scheduler2],
    milestones=[20],
)

lr.load_state_dict(torch.load("./save_seq.pt"))

# now load the optimizer checkpoint after loading the LRScheduler
optim.load_state_dict(torch.load("./save_optim.pt"))
RAW_BUFFERClick to expand / collapse

📚 The doc issue

optim.adadelta uses sgd as example.

In Adadelta the example is using SGD:

optim = torch.optim.SGD(model.parameters(), lr=3e-4)

This is a tiny mistake. Should i submit a PR to fix this?

Suggest a potential alternative/fix

model = torch.nn.Linear(10, 10)

optim = torch.optim.Adadelta(
    model.parameters(),
    lr=1.0,      # default LR
    rho=0.9,
    eps=1e-6,
)

scheduler1 = torch.optim.lr_scheduler.LinearLR(
    optim,
    start_factor=0.1,
    end_factor=1,
    total_iters=20,
)

scheduler2 = torch.optim.lr_scheduler.CosineAnnealingLR(
    optim,
    T_max=80,
    eta_min=0.01,   # scaled for Adadelta-style LR
)

lr = torch.optim.lr_scheduler.SequentialLR(
    optim,
    schedulers=[scheduler1, scheduler2],
    milestones=[20],
)

lr.load_state_dict(torch.load("./save_seq.pt"))

# now load the optimizer checkpoint after loading the LRScheduler
optim.load_state_dict(torch.load("./save_optim.pt"))

cc @svekars @sekyondaMeta @AlannaBurke @vincentqb @jbschlosser @albanD @janeyx99 @crcrpar

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix Adadelta uses SGD in its examples