Skip to content
class

Rprop

extendsOptimizer
Rprop

Rprop optimiser — Resilient Backpropagation (Riedmiller & Braun 1993).

A magnitude-free quasi-Newton method: each parameter carries its own step size which grows when the gradient sign is consistent and shrinks when it flips. Because only sign(g)\mathrm{sign}(g) enters the update, Rprop is immune to gradient-magnitude pathologies (vanishing or exploding) but is incompatible with mini-batch noise — it is a batch-mode method.

Math

Let Δt\Delta_t be the per-parameter step size and gtg_t the gradient.

Δt+1={min⁡(η+ Δt,  Δmax⁡)gt gt−1>0max⁡(η− Δt,  Δmin⁡)gt gt−1<0Δtgt gt−1=0 \Delta_{t+1} = \begin{cases} \min(\eta_+\,\Delta_t,\;\Delta_{\max}) & g_t\,g_{t-1} > 0 \\ \max(\eta_-\,\Delta_t,\;\Delta_{\min}) & g_t\,g_{t-1} < 0 \\ \Delta_t & g_t\,g_{t-1} = 0 \end{cases}

When the sign flips, gtg_t is additionally zeroed to suppress a secondary overshoot on the following step. The parameter update is

θt+1=θt−sign(gt) Δt+1 \theta_{t+1} = \theta_t - \mathrm{sign}(g_t)\,\Delta_{t+1}

References

Riedmiller & Braun, "A Direct Adaptive Method for Faster Backpropagation Learning: The RPROP Algorithm" (ICNN 1993).

See Also

RMSprop — Hinton's mini-batch-friendly replacement that still uses an EMA of g2g^2 but keeps the gradient magnitude in the update.

Parameters

paramsvector of TensorImpl
Parameters to optimise.
lrfloat, default 1e-2
Initial value placed into every element of step_size_. Despite the name this is not used as a global scale.
eta_minusfloat, default 0.5
Step-shrink factor η−\eta_- applied on sign flips.
eta_plusfloat, default 1.2
Step-grow factor η+\eta_+ applied on consistent signs.
step_minfloat, default 1e-6
Lower clamp Δmin⁡\Delta_{\min}.
step_maxfloat, default 50.0
Upper clamp Δmax⁡\Delta_{\max}.

Attributes

prev_grad_vector of Storage
Last-step gradient, used to detect sign flips.
step_size_vector of Storage
Per-element adaptive step Δ\Delta. Initialised to lr_ on every element rather than to 1.0, so the very first update has a sensible scale.

Notes

Rprop assumes deterministic gradients (full-batch). Applying it to mini-batches confuses sign-flip detection because batch noise causes spurious sign changes — accepted practice is to either use very large batches or switch to RMSprop.

Constructors

1
ctor

Rprop

void Rprop(int)

Construct the optimiser and resize per-slot state vectors.

Parameters

paramsvector of TensorImpl
Parameters to optimise.
lrfloat, default 1e-2
Initial value for every element of step_size_.
eta_minusfloat, default 0.5
Step-shrink factor.
eta_plusfloat, default 1.2
Step-grow factor.
step_minfloat, default 1e-6
Lower step clamp.
step_maxfloat, default 50.0
Upper step clamp.

Static methods

1
static

check_hyperparams

void check_hyperparams(double lr, double eta_minus, double eta_plus)

Check Rprop's hyper-parameters — the reference framework's constructor checks, run by the constructor and set_hyperparams.

Raises

InvalidArgument
If lr is negative or NaN, or the etas do not satisfy 0 < eta_minus < 1 < eta_plus.

Virtual methods

2
virtconst

lr

→float
double lr()

Return the current lr_ parameter.

Returns

float

Latest value passed to set_lr (or the constructor).

virt

set_lr

void set_lr(double lr)

Set the active learning-rate parameter.

Parameters

lrfloat
New lr_ value. This is not retroactively applied to existing step_size_ buffers — it only affects fresh allocations.

Methods

5
fn

init_state_slot

void init_state_slot(int i, const int & p)

Allocate prev_grad_ and step_size_ for parameter i.

Parameters

iint
Slot index.
Parameter whose shape/dtype/device dictates the buffer layout.

Notes

prev_grad_[i] is zero-initialised; step_size_[i] is filled with lr_ so the first step has a sensible magnitude.

fn

set_hyperparams

void set_hyperparams(double lr, double eta_minus, double eta_plus, double step_min, double step_max)

Replace the hyper-parameters between steps; nothing is applied when check_hyperparams rejects them. lr only seeds the step size of a slot that has not stepped (see set_lr).

fnconst

state_dict_id

→str
int state_dict_id()

Return the versioned state-dict identifier.

Returns

str

"rprop_v1".

fn

update_one

void update_one(int i, int & p, const int & g)

Apply one Rprop update to parameter i.

Parameters

iint
Parameter slot index.
Parameter tensor (updated in place).
gStorage
Gradient for p on this step. May be zeroed in place where the sign of g flipped relative to prev_grad_.

Notes

Drives the per-element step-size adaptation rule above and then applies −sign(g) Δ-\mathrm{sign}(g)\,\Delta to p.