25 template<
typename AFloat>
31 auto f = [&data, &temp](
UInt_t workerID)
33 temp[workerID] =
fabs(data[workerID]);
37 auto reduction = [](AFloat sum1, AFloat sum2)
47 template<
typename AFloat>
58 AFloat sign = (dataA[workerID] < 0.0) ? -1.0 : 1.0;
59 dataB[workerID] += weightDecay * sign;
67 template<
typename AFloat>
73 auto f = [&data, &temp](
UInt_t workerID)
75 temp[workerID] = data[workerID] * data[workerID];
79 auto reduction = [](AFloat sum1, AFloat sum2)
89 template<
typename AFloat>
100 dataB[workerID] += 2.0 * weightDecay * dataA[workerID];
ROOT::TThreadExecutor & GetThreadExecutor() const
static Scalar_t L1Regularization(const TCpuMatrix< Scalar_t > &W)
double weightDecay(double error, ItWeight itWeight, ItWeight itWeightEnd, double factorWeightDecay, EnumRegularization eRegularization)
compute the weight decay for regularization (L1 or L2)
static void AddL1RegularizationGradients(TCpuMatrix< Scalar_t > &A, const TCpuMatrix< Scalar_t > &W, Scalar_t weightDecay)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
AFloat * GetRawDataPointer()
Return raw pointer to the elements stored contiguously in column-major order.
static void AddL2RegularizationGradients(TCpuMatrix< Scalar_t > &A, const TCpuMatrix< Scalar_t > &W, Scalar_t weightDecay)
size_t GetNElements() const
A pseudo container class which is a generator of indices.
static Scalar_t L2Regularization(const TCpuMatrix< Scalar_t > &W)
Abstract ClassifierFactory template that handles arbitrary types.