Quickstart: Autograd Basics #
Tour of the public autograd APIs beyond ordinary training:
autograd.model.*for model-level VJP, Jacobian, and loss gradients.autograd.model.OutputLoss.*for reusable scalar losses on model outputs.autograd.fn1.*for Jacobian / Hessian APIs on single-input tensor functions.nn.functional.detachfor stop-gradient behavior.
Run:
lake exe torchlean quickstart_autograd
@[reducible, inline]
Instances For
@[reducible, inline]
Instances For
@[reducible, inline]
Instances For
@[reducible, inline]
Instances For
The tour stays on the public Float autodiff surface. It avoids:
- runtime tape/session code,
- hand-written parameter-shape bookkeeping,
- runtime scalar dispatch.
Instead, it uses TorchLean.autograd.* directly on a tiny fixed payload.
Instances For
Instances For
Deterministic model/sample payload for the autograd walkthrough.
The example stays small: one Linear layer, one input vector, one target vector, and one fixed parameter-direction for JVP/HVP queries.
- W : TorchLean.Tensor.T α WShape
- b : TorchLean.Tensor.T α BShape
- x : TorchLean.Tensor.T α XShape
- y : TorchLean.Tensor.T α YShape
- vW : TorchLean.Tensor.T α WShape
- vb : TorchLean.Tensor.T α BShape
Instances For
Fixed Float tensors used by the walkthrough.
Instances For
def
NN.Examples.Quickstart.AutogradBasics.Internal.modelParams
{α : Type}
(payload : DemoPayload α)
:
Parameter pack for the single Linear layer in model.
Instances For
def
NN.Examples.Quickstart.AutogradBasics.Internal.paramDirection
{α : Type}
(payload : DemoPayload α)
:
Direction vector in parameter space used for JVP/HVP examples.
Instances For
def
NN.Examples.Quickstart.AutogradBasics.Internal.unpackLinearParams
{α : Type}
(params : API.autograd.model.Params model α)
:
Unpack this tutorial's single Linear-layer parameter pack.
Instances For
Run the Float autograd walkthrough.
Instances For
Command-line help for the Float autograd quickstart.