[optimization] for the FTRL and SGD optimizers, use the new *_array_sum_sq function to do L2 regularization, vs. the L2 norm which will use the linear algebra meaning
This commit is contained in:
@@ -210,6 +210,14 @@
|
||||
return sqrt((double)result); \
|
||||
} \
|
||||
\
|
||||
static inline unsigned_type name##_sum_sq(type *array, size_t n) { \
|
||||
unsigned_type result = 0; \
|
||||
for (size_t i = 0; i < n; i++) { \
|
||||
result += array[i] * array[i]; \
|
||||
} \
|
||||
return result; \
|
||||
} \
|
||||
\
|
||||
static inline double name##_mean(type *array, size_t n) { \
|
||||
unsigned_type sum = name##_sum(array, n); \
|
||||
return (double)sum / n; \
|
||||
|
||||
Reference in New Issue
Block a user