René's URL Explorer Experiment


Title: Second-Order Optimizers — PyTorch main documentation

Description: Second-order optimizers in PyTorch C++ — LBFGS optimizer for full-batch optimization.

Keywords:

direct link

Domain: docs.pytorch.org


Hey, it has json ld scripts:
    {
       "@context": "https://schema.org",
       "@type": "Article",
       "name": "Second-Order Optimizers",
       "headline": "Second-Order Optimizers",
       "description": "Second-order optimizers in PyTorch C++ \u2014 LBFGS optimizer for full-batch optimization.",
       "url": "/api/optim/second_order.html",
       "articleBody": "Second-Order Optimizers# Second-order methods use curvature information (Hessian or its approximations) to make better optimization steps. They can converge faster but are more computationally expensive and memory-intensive. LBFGS (Limited-memory Broyden-Fletcher-Goldfarb-Shanno)# LBFGS is a quasi-Newton method that approximates the inverse Hessian using gradient history. It can converge much faster than first-order methods for smooth, convex-like loss surfaces. When to use: Small models where memory isn\u2019t a concern Fine-tuning pre-trained models Convex or near-convex optimization problems Full-batch training (not mini-batch) Key parameters: lr: Learning rate (often 1.0 for LBFGS) max_iter: Maximum iterations per step history_size: Number of past gradients to store Important: LBFGS requires a closure function that recomputes the loss. class LBFGS : public torch::optim::Optimizer# Public Functions inline explicit LBFGS(const std::vector\u003cOptimizerParamGroup\u003e \u0026param_groups, LBFGSOptions defaults = {})# inline explicit LBFGS(std::vector\u003cTensor\u003e params, LBFGSOptions defaults = {})# virtual Tensor step(LossClosure closure) override# A loss function closure, which is expected to return the loss value. virtual void save(serialize::OutputArchive \u0026archive) const override# Serializes the optimizer state into the given archive. virtual void load(serialize::InputArchive \u0026archive) override# Deserializes the optimizer state from the given archive. Example: auto optimizer = torch::optim::LBFGS( model-\u003eparameters(), torch::optim::LBFGSOptions(1.0) .max_iter(20) .history_size(10)); // LBFGS requires a closure that recomputes the model for (int epoch = 0; epoch \u003c num_epochs; ++epoch) { auto closure = [\u0026]() { optimizer.zero_grad(); auto output = model-\u003eforward(data); auto loss = loss_fn(output, target); loss.backward(); return loss; }; optimizer.step(closure); }",
       "author": {
         "@type": "Organization",
         "name": "PyTorch Contributors",
         "url": "https://pytorch.org"
       },
       "image": "https://pytorch.org/docs/stable/_static/img/pytorch_seo.png",
       "mainEntityOfPage": {
         "@type": "WebPage",
         "@id": "/api/optim/second_order.html"
       },
       "datePublished": "2023-01-01T00:00:00Z",
       "dateModified": "2023-01-01T00:00:00Z"
     }
 

docsearch:languageen
llm:site-typedocumentation
llm:frameworkPyTorch
llm:descriptionSecond-order optimizers in PyTorch C++ — LBFGS optimizer for full-batch optimization.
llm:navigation-filehttps://pytorch.org/docs/stable/llms.txt
llm:sitemaphttps://pytorch.org/docs/stable/sitemap.xml
llm:versionmain
llm:projectPyTorch
llm:page-typedocumentation
og:imagehttps://docs.pytorch.org/docs/stable/_static/img/pytorch_seo.png
None3

Links:

Skip to main contenthttps://docs.pytorch.org/cppdocs/api/optim/second_order.html#main-content
Home https://docs.pytorch.org/cppdocs/index.html
mainhttps://docs.pytorch.org/cppdocs/index.html
Installing C++ Distributions of PyTorch https://docs.pytorch.org/cppdocs/installing.html
The C++ Frontend https://docs.pytorch.org/cppdocs/frontend.html
C++ API Reference https://docs.pytorch.org/cppdocs/api/index.html
ATen: Tensor Library https://docs.pytorch.org/cppdocs/api/aten/index.html
C10: Core Utilities https://docs.pytorch.org/cppdocs/api/c10/index.html
Autograd: Automatic Differentiation https://docs.pytorch.org/cppdocs/api/autograd/index.html
CUDA Support https://docs.pytorch.org/cppdocs/api/cuda/index.html
XPU Support https://docs.pytorch.org/cppdocs/api/xpu/index.html
Neural Network Modules (torch::nn) https://docs.pytorch.org/cppdocs/api/nn/index.html
Optimizers (torch::optim) https://docs.pytorch.org/cppdocs/api/optim/index.html
Data Loading (torch::data) https://docs.pytorch.org/cppdocs/api/data/index.html
Serialization (torch::serialize) https://docs.pytorch.org/cppdocs/api/serialize/index.html
Torch Library API https://docs.pytorch.org/cppdocs/api/library/index.html
Torch Stable API https://docs.pytorch.org/cppdocs/api/stable/index.html
FAQ https://docs.pytorch.org/cppdocs/faq.html
Go to pytorch.org https://pytorch.org
Xhttps://x.com/PyTorch
GitHubhttps://github.com/pytorch/pytorch
PyTorch Forumhttps://discuss.pytorch.org/
PyPihttps://pypi.org/project/torch/
mainhttps://docs.pytorch.org/cppdocs/index.html
Installing C++ Distributions of PyTorch https://docs.pytorch.org/cppdocs/installing.html
The C++ Frontend https://docs.pytorch.org/cppdocs/frontend.html
C++ API Reference https://docs.pytorch.org/cppdocs/api/index.html
ATen: Tensor Library https://docs.pytorch.org/cppdocs/api/aten/index.html
C10: Core Utilities https://docs.pytorch.org/cppdocs/api/c10/index.html
Autograd: Automatic Differentiation https://docs.pytorch.org/cppdocs/api/autograd/index.html
CUDA Support https://docs.pytorch.org/cppdocs/api/cuda/index.html
XPU Support https://docs.pytorch.org/cppdocs/api/xpu/index.html
Neural Network Modules (torch::nn) https://docs.pytorch.org/cppdocs/api/nn/index.html
Optimizers (torch::optim) https://docs.pytorch.org/cppdocs/api/optim/index.html
Data Loading (torch::data) https://docs.pytorch.org/cppdocs/api/data/index.html
Serialization (torch::serialize) https://docs.pytorch.org/cppdocs/api/serialize/index.html
Torch Library API https://docs.pytorch.org/cppdocs/api/library/index.html
Torch Stable API https://docs.pytorch.org/cppdocs/api/stable/index.html
FAQ https://docs.pytorch.org/cppdocs/faq.html
Go to pytorch.org https://pytorch.org
Xhttps://x.com/PyTorch
GitHubhttps://github.com/pytorch/pytorch
PyTorch Forumhttps://discuss.pytorch.org/
PyPihttps://pypi.org/project/torch/
ATen: Tensor Libraryhttps://docs.pytorch.org/cppdocs/api/aten/index.html
Tensor Classhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html
Tensor Creationhttps://docs.pytorch.org/cppdocs/api/aten/creation.html
Tensor Indexinghttps://docs.pytorch.org/cppdocs/api/aten/indexing.html
Tensor Accessorshttps://docs.pytorch.org/cppdocs/api/aten/accessors.html
C10: Core Utilitieshttps://docs.pytorch.org/cppdocs/api/c10/index.html
Device and DeviceTypehttps://docs.pytorch.org/cppdocs/api/c10/device.html
Device Guardshttps://docs.pytorch.org/cppdocs/api/c10/guards.html
Streamshttps://docs.pytorch.org/cppdocs/api/c10/streams.html
Core Typeshttps://docs.pytorch.org/cppdocs/api/c10/types.html
Utilitieshttps://docs.pytorch.org/cppdocs/api/c10/utilities.html
Autograd: Automatic Differentiationhttps://docs.pytorch.org/cppdocs/api/autograd/index.html
Gradient Computationhttps://docs.pytorch.org/cppdocs/api/autograd/gradient.html
Custom Autograd Functionshttps://docs.pytorch.org/cppdocs/api/autograd/custom_functions.html
Gradient Modeshttps://docs.pytorch.org/cppdocs/api/autograd/modes.html
CUDA Supporthttps://docs.pytorch.org/cppdocs/api/cuda/index.html
CUDA Streamshttps://docs.pytorch.org/cppdocs/api/cuda/streams.html
CUDA Guardshttps://docs.pytorch.org/cppdocs/api/cuda/guards.html
CUDA Utility Functionshttps://docs.pytorch.org/cppdocs/api/cuda/utilities.html
XPU Supporthttps://docs.pytorch.org/cppdocs/api/xpu/index.html
XPU Streamshttps://docs.pytorch.org/cppdocs/api/xpu/streams.html
XPU Utility Functionshttps://docs.pytorch.org/cppdocs/api/xpu/utilities.html
Neural Network Modules (torch::nn)https://docs.pytorch.org/cppdocs/api/nn/index.html
Containershttps://docs.pytorch.org/cppdocs/api/nn/containers.html
Convolution Layershttps://docs.pytorch.org/cppdocs/api/nn/convolution.html
Pooling Layershttps://docs.pytorch.org/cppdocs/api/nn/pooling.html
Linear Layershttps://docs.pytorch.org/cppdocs/api/nn/linear.html
Activation Functionshttps://docs.pytorch.org/cppdocs/api/nn/activation.html
Normalization Layershttps://docs.pytorch.org/cppdocs/api/nn/normalization.html
Dropout Layershttps://docs.pytorch.org/cppdocs/api/nn/dropout.html
Embedding Layershttps://docs.pytorch.org/cppdocs/api/nn/embedding.html
Recurrent Layershttps://docs.pytorch.org/cppdocs/api/nn/recurrent.html
Transformer Layershttps://docs.pytorch.org/cppdocs/api/nn/transformer.html
Loss Functionshttps://docs.pytorch.org/cppdocs/api/nn/loss.html
Functional APIhttps://docs.pytorch.org/cppdocs/api/nn/functional.html
Utilitieshttps://docs.pytorch.org/cppdocs/api/nn/utilities.html
Optimizers (torch::optim)https://docs.pytorch.org/cppdocs/api/optim/index.html
Gradient Descent Optimizershttps://docs.pytorch.org/cppdocs/api/optim/gradient_descent.html
Adaptive Learning Rate Optimizershttps://docs.pytorch.org/cppdocs/api/optim/adaptive.html
Second-Order Optimizershttps://docs.pytorch.org/cppdocs/api/optim/second_order.html
Learning Rate Schedulershttps://docs.pytorch.org/cppdocs/api/optim/schedulers.html
Data Loading (torch::data)https://docs.pytorch.org/cppdocs/api/data/index.html
Datasetshttps://docs.pytorch.org/cppdocs/api/data/datasets.html
DataLoaderhttps://docs.pytorch.org/cppdocs/api/data/dataloader.html
Samplershttps://docs.pytorch.org/cppdocs/api/data/samplers.html
Transformshttps://docs.pytorch.org/cppdocs/api/data/transforms.html
Serialization (torch::serialize)https://docs.pytorch.org/cppdocs/api/serialize/index.html
Saving and Loadinghttps://docs.pytorch.org/cppdocs/api/serialize/save_load.html
Archiveshttps://docs.pytorch.org/cppdocs/api/serialize/archives.html
Checkpointshttps://docs.pytorch.org/cppdocs/api/serialize/checkpoints.html
Torch Library APIhttps://docs.pytorch.org/cppdocs/api/library/index.html
Operator Registrationhttps://docs.pytorch.org/cppdocs/api/library/registration.html
Custom Classeshttps://docs.pytorch.org/cppdocs/api/library/custom_classes.html
Library Versioninghttps://docs.pytorch.org/cppdocs/api/library/versioning.html
Torch Stable APIhttps://docs.pytorch.org/cppdocs/api/stable/index.html
Library Registration Macroshttps://docs.pytorch.org/cppdocs/api/stable/registration.html
Stable Operatorshttps://docs.pytorch.org/cppdocs/api/stable/operators.html
Utilitieshttps://docs.pytorch.org/cppdocs/api/stable/utilities.html
https://docs.pytorch.org/cppdocs/index.html
C++ API Referencehttps://docs.pytorch.org/cppdocs/api/index.html
Optimizers (torch::optim)https://docs.pytorch.org/cppdocs/api/optim/index.html
#https://docs.pytorch.org/cppdocs/api/optim/second_order.html#second-order-optimizers
#https://docs.pytorch.org/cppdocs/api/optim/second_order.html#lbfgs-limited-memory-broyden-fletcher-goldfarb-shanno
Optimizerhttps://docs.pytorch.org/cppdocs/api/optim/index.html#_CPPv4N5torch5optim9OptimizerE
#https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGSE
OptimizerParamGrouphttps://docs.pytorch.org/cppdocs/api/optim/index.html#_CPPv4N5torch5optim19OptimizerParamGroupE
#https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGS5LBFGSERKNSt6vectorI19OptimizerParamGroupEE12LBFGSOptions
Tensorhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv46Tensorv
#https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGS5LBFGSENSt6vectorI6TensorEE12LBFGSOptions
Tensorhttps://docs.pytorch.org/cppdocs/api/aten/tensor.html#_CPPv46Tensorv
#https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGS4stepE11LossClosure
OutputArchivehttps://docs.pytorch.org/cppdocs/api/serialize/archives.html#_CPPv4N5torch9serialize13OutputArchiveE
#https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4NK5torch5optim5LBFGS4saveERN9serialize13OutputArchiveE
InputArchivehttps://docs.pytorch.org/cppdocs/api/serialize/archives.html#_CPPv4N5torch9serialize12InputArchiveE
#https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGS4loadERN9serialize12InputArchiveE
previous Adaptive Learning Rate Optimizers https://docs.pytorch.org/cppdocs/api/optim/adaptive.html
next Learning Rate Schedulers https://docs.pytorch.org/cppdocs/api/optim/schedulers.html
PyData Sphinx Themehttps://pydata-sphinx-theme.readthedocs.io/en/stable/index.html
previous Adaptive Learning Rate Optimizers https://docs.pytorch.org/cppdocs/api/optim/adaptive.html
next Learning Rate Schedulers https://docs.pytorch.org/cppdocs/api/optim/schedulers.html
LBFGS (Limited-memory Broyden-Fletcher-Goldfarb-Shanno)https://docs.pytorch.org/cppdocs/api/optim/second_order.html#lbfgs-limited-memory-broyden-fletcher-goldfarb-shanno
torch::optim::LBFGShttps://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGSE
LBFGS()https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGS5LBFGSERKNSt6vectorI19OptimizerParamGroupEE12LBFGSOptions
LBFGS()https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGS5LBFGSENSt6vectorI6TensorEE12LBFGSOptions
step()https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGS4stepE11LossClosure
save()https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4NK5torch5optim5LBFGS4saveERN9serialize13OutputArchiveE
load()https://docs.pytorch.org/cppdocs/api/optim/second_order.html#_CPPv4N5torch5optim5LBFGS4loadERN9serialize12InputArchiveE
Show Source https://docs.pytorch.org/cppdocs/_sources/api/optim/second_order.md.txt
ExecuTorchhttps://docs.pytorch.org/executorch
Helionhttps://docs.pytorch.org/helion
torchaohttps://docs.pytorch.org/ao
kinetohttps://github.com/pytorch/kineto
torchtitanhttps://github.com/pytorch/torchtitan
TorchRLhttps://docs.pytorch.org/rl
torchvisionhttps://docs.pytorch.org/vision
torchaudiohttps://docs.pytorch.org/audio
tensordicthttps://docs.pytorch.org/tensordict
PyTorch on XLA Deviceshttps://docs.pytorch.org/xla
View Docshttps://docs.pytorch.org/docs/stable/index.html
View Tutorialshttps://docs.pytorch.org/tutorials
View Resourceshttps://pytorch.org/resources
Privacy Policyhttps://www.linuxfoundation.org/privacy/
https://www.facebook.com/pytorch
https://twitter.com/pytorch
https://www.youtube.com/pytorch
https://www.linkedin.com/company/pytorch
https://pytorch.slack.com
https://pytorch.org/wechat
Policieshttps://www.linuxfoundation.org/legal/policies
Trademark Usagehttps://www.linuxfoundation.org/trademark-usage
Privacy Policyhttp://www.linuxfoundation.org/privacy
Cookies Policyhttps://opensource.fb.com/legal/cookie-policy
Sphinxhttps://www.sphinx-doc.org/
PyData Sphinx Themehttps://pydata-sphinx-theme.readthedocs.io/en/stable/index.html

Viewport: width=device-width, initial-scale=1


URLs of crawlers that visited me.