25 template<
typename AFloat>
33 temp[workerID] =
fabs(data[workerID]);
37 auto reduction = [](
const std::vector<AFloat> &
v )
39 return std::accumulate(
v.begin(),
v.end(),AFloat{});
51 template<
typename AFloat>
62 AFloat sign = (dataA[workerID] < 0.0) ? -1.0 : 1.0;
63 dataB[workerID] += weightDecay * sign;
71 template<
typename AFloat>
79 temp[workerID] = data[workerID] * data[workerID];
83 auto reduction = [](
const std::vector<AFloat> &
v )
85 return std::accumulate(
v.begin(),
v.end(),AFloat{});
97 template<
typename AFloat>
108 dataB[workerID] += 2.0 * weightDecay * dataA[workerID];
size_t GetNElements() 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)
auto Reduce(const std::vector< T > &objs, BINARYOP redfunc) -> decltype(redfunc(objs.front(), objs.front()))
"Reduce" an std::vector into a single object in parallel by passing a binary operator as the second a...
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)
A pseudo container class which is a generator of indices.
static Scalar_t L2Regularization(const TCpuMatrix< Scalar_t > &W)
ROOT::TThreadExecutor & GetThreadExecutor() const
Abstract ClassifierFactory template that handles arbitrary types.
auto Map(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Execute func (with no arguments) nTimes in parallel.