Fix remaining nonexistent AdamOptions::beta1 calls in C++ frontend tutorial#3934
Fix remaining nonexistent AdamOptions::beta1 calls in C++ frontend tutorial#3934David-Wu1119 wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3934
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @David-Wu1119! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
There was a problem hiding this comment.
Pull request overview
This PR updates the C++ frontend tutorial (advanced_source/cpp_frontend.rst) so the checkpoint-restore code snippet compiles with current LibTorch by removing calls to the nonexistent AdamOptions::beta1 setter and using AdamOptions::betas(...) instead.
Changes:
- Replace
torch::optim::AdamOptions(...).beta1(0.5)withtorch::optim::AdamOptions(...).betas(std::make_tuple(...))in the checkpoint-restore snippet. - Align the checkpoint-restore snippet with the approach already applied elsewhere in the tutorial (per PR #2260).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| torch::optim::Adam generator_optimizer( | ||
| generator->parameters(), torch::optim::AdamOptions(2e-4).beta1(0.5)); | ||
| generator->parameters(), torch::optim::AdamOptions(2e-4).betas(std::make_tuple(0.5, 0.5))); | ||
| torch::optim::Adam discriminator_optimizer( | ||
| discriminator->parameters(), torch::optim::AdamOptions(2e-4).beta1(0.5)); | ||
| discriminator->parameters(), torch::optim::AdamOptions(2e-4).betas(std::make_tuple(0.5, 0.5))); |
Fixes pytorch/pytorch#47351
The checkpoint-restore snippet in the C++ frontend tutorial still uses
torch::optim::AdamOptions(2e-4).beta1(0.5)— thebeta1member no longer exists (adam.hdefines onlyTORCH_ARG(betas_t, betas)), so the snippet doesn't compile.#2260 fixed the identical calls earlier in the tutorial (training-loop section) but missed these two occurrences in the checkpoint-restore block. This applies the same
betas(std::make_tuple(0.5, 0.5))form to the remaining two, making the file consistent.(Prepared with AI assistance; reviewed by the author.)