25 template<
typename Real_t>
34 for (
size_t i = 0; i <
m; i++) {
35 for (
size_t j = 0; j <
n; j++) {
36 result += std::abs(W(i,j));
43 template<
typename Real_t>
54 for (
size_t i = 0; i <
m; i++) {
55 for (
size_t j = 0; j <
n; j++) {
56 sign = (W(i,j) > 0.0) ? 1.0 : -1.0;
63 template<
typename Real_t>
72 for (
size_t i = 0; i <
m; i++) {
73 for (
size_t j = 0; j <
n; j++) {
74 result += W(i,j) * W(i,j);
81 template<
typename Real_t>
90 for (
size_t i = 0; i <
m; i++) {
91 for (
size_t j = 0; j <
n; j++) {
92 A(i,j) += weightDecay * 2.0 * W(i,j);
static void AddL2RegularizationGradients(TMatrixT< AReal > &A, const TMatrixT< AReal > &W, AReal weightDecay)
double weightDecay(double error, ItWeight itWeight, ItWeight itWeightEnd, double factorWeightDecay, EnumRegularization eRegularization)
compute the weight decay for regularization (L1 or L2)
static AReal L1Regularization(const TMatrixT< AReal > &W)
static void AddL1RegularizationGradients(TMatrixT< AReal > &A, const TMatrixT< AReal > &W, AReal weightDecay)
static AReal L2Regularization(const TMatrixT< AReal > &W)
Abstract ClassifierFactory template that handles arbitrary types.