mirror of
https://github.com/HuwCampbell/grenade.git
synced 2024-11-28 19:29:08 +03:00
14 lines
439 B
C
14 lines
439 B
C
|
#include "gradient_decent.h"
|
||
|
|
||
|
void decend_cpu(int len, double rate, double momentum, double regulariser,
|
||
|
const double* weights,
|
||
|
const double* gradient,
|
||
|
const double* last,
|
||
|
double* outputWeights, double* outputMomentum) {
|
||
|
|
||
|
for (int i = 0; i <= len; i++) {
|
||
|
outputMomentum[i] = momentum * last[i] - rate * gradient[i];
|
||
|
outputWeights[i] = weights[i] + outputMomentum[i] - (rate * regulariser) * weights[i];
|
||
|
}
|
||
|
}
|