Skip to content

Training, adaptation, compression, and systems techniques · Training, fine-tuning, adaptation, compression, and systems techniques · TRN002 · Training method

Adam

Adapts coordinate-wise steps using moving first and second gradient moments. Common in language, audio, and generative model training.

Runs in CodeSplash Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method runs this entry in Python and R. Set it up from the method's page.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Runs in CodeSplash
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through decide.offline_rl, decide.rl_dqn, decide.rl_ppo, discover.autoencoder, discover.contrastive, discover.dagmm, discover.deep_svdd, discover.graph_embed, discover.ts_embed, discover.vae, forecast.deepar, forecast.nbeats, forecast.nhits, forecast.patchtst, forecast.rnn, forecast.tcn, forecast.tft, forecast.timegrad, learn.cnn, learn.dann, learn.deep_ensemble, learn.ft_transformer, learn.gnn, learn.neural_cde, learn.set_model, learn.tabm, learn.tabnet, learn.torch_mlp, missing.csdi, simulate.calibrate, synth.flow, synth.flow_matching, synth.tvae. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Adapts coordinate-wise steps using moving first and second gradient moments. Common in language, audio, and generative model training.

Question / hypotheses

Does this intervention improve the intended quality, adaptation, resource, or reliability objective under a controlled comparison? It defines a method, not an intrinsic null-hypothesis test.

Architecture / computational structure

Each trainable tensor has first/second-moment buffers and a step counter; bias correction modifies early updates.

Assumptions

Differentiable or subdifferentiable objectives and numerically stable gradients are required. Adaptive steps do not guarantee convergence for arbitrary nonconvex or adversarial objectives.

Formula / computational definition

mt=β1mt−1+(1−β1)gt, vt=β2vt−1+(1−β2)gt2, θ←θ−ηm^t/(v^t+ϵ).m_t=\beta_1m_{t-1}+(1-\beta_1)g_t,\ v_t=\beta_2v_{t-1}+(1-\beta_2)g_t^2,\ \theta\leftarrow\theta-\eta\hat m_t/(\sqrt{\hat v_t}+\epsilon).

Parameters and notation

Learned: theta. State: m,v,t with m-hat=m/(1-beta1^t), v-hat=v/(1-beta2^t). Hyperparameters: eta, beta1, beta2, epsilon, batch size, schedule; implementation variants must be named.

Fitting, fine-tuning, and adaptation

Use separate learning-rate groups when adapting pretrained modules. Reset or retain moment buffers deliberately. Validate low-precision epsilon behavior and distinguish coupled L2 penalties from AdamW.

How to use and calibrate

Inspect effective update norms and held-out loss across seeds. Example: optimize an autoencoder while comparing representation utility with reconstruction alone.

Example application

optimize an autoencoder while comparing representation utility with reconstruction alone.

Interpretation / pitfalls

Watch out

The original paper’s convergence discussion does not prove universal convergence. Optimizer moments consume substantial memory, and a shared default learning rate is not optimal for every architecture.

Python and R code examples

Scope: numerical mechanism demonstration. Validation: Python executed successfully on the supplied synthetic inputs; R reviewed but not executed (Rscript unavailable).

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — numerical mechanism demonstration. · needs numpy

import numpy as np
g=np.array([.2,-.4]); b1=.9; b2=.999; m=(1-b1)*g; v=(1-b2)*g*g
w=np.ones(2)-.001*(m/(1-b1))/(np.sqrt(v/(1-b2))+1e-8); print(w)
R

Component demo, not a trained model — numerical mechanism demonstration.

g <- c(.2,-.4); b1 <- .9; b2 <- .999; m <- (1-b1)*g; v <- (1-b2)*g*g
w <- rep(1,2)-.001*(m/(1-b1))/(sqrt(v/(1-b2))+1e-8); print(w)

Sources

From the CodeSplash reference, entry TRN002.