neuralnetworks.optimizer.gradient-descent
gradient-descent
(gradient-descent initial-learning-rate learning-rate-update-rate)
Creates new instance of gradient descent optimizer. It uses Backtracking Line Search to find the good value of learning-rate (alpha) to allows it converge faster
To disable backtracking line search, simply set the learning-rate-update-rate to 1.0
Learning-rate-update-rate must be between (0, 1]
Cost function must returns both gradients
and cost
value
{:cost 1.5142
:gradients [1.2 -0.5]}
line-search
(line-search cost-fn init-alpha beta thetas theta-gradients)
Uses backtrack line search algorithm to find the best learning-rate (alpha) value.
Backtrack will stop if either of the following conditions are met:
- Cost of new theta (updated theta - i.e. theta is updated with alpha and gradients) is less or equals to cost of the original theta minus gradient length squared with alpha
- Approximately alpha reaches almost zero (1e-10)
- Approximately all gradients almost zero (1e-10)
Reference: Gradient Descent Revisited
update-thetas
(update-thetas thetas theta-gradients alpha)
Updates the thetas (weight) based on the provided gradients and alpha. Gradients must be the same dimension as thetas