gradient-descent
Version:
Module to iterate over a numerically function to Gradient Descent direction
23 lines (16 loc) • 738 B
Markdown
Module to iterate over a numerically function to Gradient Descent direction
The module expose a function with next params
Iterate NUM_STEPS and stop when the norm of gradient is less that PRESICION,
every step is of size STEP_SIZE and the numerical derivate is aproximated by:
derivate = [f(x + DELTA_SIZE) - f(x)]/DELTA_SIZE
```js
const optimze = require('gradient-descent')
const func = async (x, y, z) => x * x + y * y + z * z;
const init = [3, 4, 5]; // dimension is obtained from initial point
const res = await optimize(init, func);
assert(await func(...res) < await func(...init));
```