24 template<
typename AFloat>
25 void TCpu<AFloat>::Sigmoid(TCpuMatrix<AFloat> & B,
26 const TCpuMatrix<AFloat> & A)
28 auto f = [](AFloat x) {
return 1.0 / (1.0 + exp(-x));};
32 template<
typename AFloat>
33 void TCpu<AFloat>::Softmax(TCpuMatrix<AFloat> & B,
34 const TCpuMatrix<AFloat> & A)
36 const AFloat *dataA = A.GetRawDataPointer();
37 AFloat *dataB = B.GetRawDataPointer();
38 size_t n = A.GetNcols();
39 size_t m = A.GetNrows();
41 auto f = [&dataA, &dataB, n, m](UInt_t workerID)
44 for (
size_t i = 0; i < n; i++) {
45 sum += exp(dataA[workerID + i * m]);
47 for (
size_t i = 0; i < n; i++) {
48 dataB[workerID + i * m] = exp(dataA[workerID + i * m]) / sum;
53 B.GetThreadExecutor().Map(f, ROOT::TSeqI(A.GetNrows()));