Skip to content

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

AdamW and decoupled weight decay

Separates parameter shrinkage from Adam’s adaptive gradient transformation.

Runs in CodeSplash (Experimental) 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. The methods that run it are Experimental.

Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.

Availability
Runs in CodeSplash (Experimental)
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 learn.cnn, learn.deep_ensemble, learn.ft_transformer, learn.tabm, learn.tabnet. 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

Separates parameter shrinkage from Adam’s adaptive gradient transformation.

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

Adam moment updates are accompanied by a direct weight-decay step on selected parameter groups.

Assumptions

Parameter-group rules must be explicit; normalization gains and biases are often treated differently. Learning-rate and decay schedules jointly determine cumulative shrinkage.

Formula / computational definition

θt+1=(1−ηtλ)θt−ηtm^t/(v^t+ϵ).\theta_{t+1}=(1-\eta_t\lambda)\theta_t-\eta_t\hat m_t/(\sqrt{\hat v_t}+\epsilon).

Parameters and notation

Learned: model weights. State: Adam moments. Hyperparameters: learning rate, weight decay lambda, betas, epsilon, exclusions, schedule. Lambda is not the same operation as adding an L2 gradient inside Adam.

Fitting, fine-tuning, and adaptation

Apply decay only to the intended trainable groups; frozen backbone weights should not silently drift. Tune adapter/head decay separately where useful and preserve optimizer configuration in checkpoints.

How to use and calibrate

Compare validation performance across a log-spaced learning-rate/decay search. Example: adapt a transformer encoder with head and backbone learning rates.

Example application

adapt a transformer encoder with head and backbone learning rates.

Interpretation / pitfalls

Watch out

A library parameter named weight_decay may implement a different operation in a different optimizer. Reducing the number of training steps also changes total shrinkage.

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
w=np.array([1.,2.]); adaptive_step=np.array([.3,-.2]); eta=.01; decay=.1
print((1-eta*decay)*w-eta*adaptive_step)
R

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

w <- c(1,2); step <- c(.3,-.2); eta <- .01; decay <- .1
print((1-eta*decay)*w-eta*step)

Sources

From the CodeSplash reference, entry TRN003.