Expand description
Weight-update rules for the trainable networks, ported from tinymind (C++)
cpp/adam.hpp and cpp/rmsprop.hpp (C++ TransferFunctionOptimizerPolicy).
A network’s optimizer is a type parameter, as in C++: Sgd (the default,
zero-sized, so a network without an adaptive optimizer pays nothing for this),
Adam or RmsProp, or for f32 and f64 networks AdamFloat and
RmsPropFloat (C++ AdamOptimizerFloat, RmsPropOptimizerFloat; feature
std or libm). Pass an adaptive optimizer with its hyperparameters to
with_optimizer on NeuralNetwork,
MultilayerPerceptron or
LstmNetwork. Weight decay and a
learning-rate schedule wrap any of them (training).
Every optimizer updates the bias weights as it updates the other weights,
and the network’s gradient clipping applies to both. Adam’s step count t
advances once per training step, before any weight moves.
The first and second moments live in the connection’s delta-weight slots, as in tinymind (C++), so an adaptive optimizer needs no extra memory per weight.
Structs§
- Adam
- Adam (C++
AdamOptimizer): per-weight first and second moment estimates with bias correction by1 - beta^t,beta^tkept as a running product (one multiply per training step). Uses the network’s learning rate; the momentum and acceleration rates do not apply. - Adam
Float - Adam for floating-point networks (C++
AdamOptimizerFloat): the hyperparameters aref64, as in the C++, cast to the network’s type where they are used, and from the first training step bias correction divides by1 - beta^t, withbeta^ta running product inf64. The square root is taken inf64. - RmsProp
- RMSprop (C++
RmsPropOptimizer): each weight’s step is scaled by a running root mean square of its gradients. Uses the network’s learning rate only.RmsProp::<Q16_16>::default()andRmsProp::<Q8_8>::default()are tinymind (C++)’s defaults: decay 0.9 and epsilon 1e-8, each rounded to the format and kept above 0 (epsilon is then one LSB). - RmsProp
Float - RMSprop for floating-point networks (C++
RmsPropOptimizerFloat): the hyperparameters aref64, cast to the network’s type where they are used, and the square root is taken inf64. - Sgd
- Stochastic gradient descent with momentum and acceleration (the default;
C++
NullOptimizerPolicy). The rates are the network’sset_learning_rate,set_momentum_rateandset_acceleration_rate. In fixed point the steplearning rate * gradientrounds to nearest (Scalar::mul_round_nearest), so steps below one LSB do not drift one way, and the momentum and acceleration products round toward zero (Scalar::mul_round_toward_zero), so a delta weight no gradient refreshes decays to 0.