2017-09-25 12:56:42 +03:00
|
|
|
#include "gradient_descent.h"
|
2016-12-20 08:31:09 +03:00
|
|
|
|
2017-09-25 12:56:42 +03:00
|
|
|
void descend_cpu(int len, double rate, double momentum, double regulariser,
|
2016-12-20 08:31:09 +03:00
|
|
|
const double* weights,
|
|
|
|
const double* gradient,
|
|
|
|
const double* last,
|
|
|
|
double* outputWeights, double* outputMomentum) {
|
|
|
|
|
2017-09-25 12:33:38 +03:00
|
|
|
for (int i = 0; i < len; i++) {
|
2016-12-20 08:31:09 +03:00
|
|
|
outputMomentum[i] = momentum * last[i] - rate * gradient[i];
|
|
|
|
outputWeights[i] = weights[i] + outputMomentum[i] - (rate * regulariser) * weights[i];
|
|
|
|
}
|
|
|
|
}
|