gradient-descent
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -19,5 +19,5 @@ /* eslint-disable no-await-in-loop */ | ||
get_error, | ||
STEP_SIZE = 1, | ||
STEP_SIZE = 0.3, | ||
DELTA_SIZE = STEP_SIZE.DELTA_SIZE || 1, | ||
NUM_STEPS = STEP_SIZE.NUM_STEPS || 10, | ||
NUM_STEPS = STEP_SIZE.NUM_STEPS || 15, | ||
PRESICION = STEP_SIZE.NUM_STEPS || STEP_SIZE || 1, | ||
@@ -44,2 +44,3 @@ ) => { | ||
} | ||
const normOfDerivate = norm_of_vector(derivate); | ||
@@ -49,4 +50,4 @@ | ||
const stepNormalized = -1 * STEP_SIZE / normOfDerivate; | ||
const stepInDerivateDirection = scalar_product(derivate, stepNormalized); | ||
const stepInDerivateDirection = scalar_product(derivate, -1 * STEP_SIZE); | ||
x_n_minus_1 = add_lists(x_n, stepInDerivateDirection); | ||
@@ -53,0 +54,0 @@ Error_n_minus_1 = await get_error(...x_n_minus_1); |
{ | ||
"name": "gradient-descent", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,6 +7,8 @@ const assert = require('assert'); | ||
const func = async (x, y, z) => x * x + y * y + z * z; | ||
const init = [3, 4, 5]; | ||
const init = [3, 4, 7]; | ||
const res = await optimize(init, func); | ||
console.log('res ', res); | ||
assert(await func(...res) < await func(...init)); | ||
}); | ||
}); |
14860