MCPcopy Create free account
hub / github.com/catboost/catboost / CalcSoftmax

Function CalcSoftmax

catboost/libs/model/eval_processing.h:15–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include <cmath>
14
15inline void CalcSoftmax(const TConstArrayRef<double> approx, TArrayRef<double> softmax) {
16 double maxApprox = *MaxElement(approx.begin(), approx.end());
17 for (size_t dim = 0; dim < approx.size(); ++dim) {
18 softmax[dim] = approx[dim] - maxApprox;
19 }
20 NCB::FastExpWithInfInplace(softmax.data(), softmax.ysize());
21 double sumExpApprox = 0;
22 for (auto curSoftmax : softmax) {
23 sumExpApprox += curSoftmax;
24 }
25 for (auto& curSoftmax : softmax) {
26 curSoftmax /= sumExpApprox;
27 }
28}
29
30inline TVector<double> CalcExponent(TVector<double> approx) {
31 NCB::FastExpWithInfInplace(approx.data(), approx.ysize());

Callers 4

PostprocessBlockMethod · 0.70
CalcDersMultiMethod · 0.50
GetProbabilityMeanValuesFunction · 0.50
EvalMethod · 0.50

Calls 7

MaxElementFunction · 0.85
FastExpWithInfInplaceFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
ysizeMethod · 0.45

Tested by

no test coverage detected