Logo ROOT   6.08/07
Reference Guide
OutputFunctions.cxx
Go to the documentation of this file.
1 // @(#)root/tmva/tmva/dnn:$Id$
2 // Author: Simon Pfreundschuh 11/07/16
3 
4 /*************************************************************************
5  * Copyright (C) 2016, Simon Pfreundschuh *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 ////////////////////////////////////////////////////////////////
13 // Explicit instantiation of the TReference architecture class //
14 // template for Double_t scalar types. //
15 ////////////////////////////////////////////////////////////////
16 
17 namespace TMVA {
18 namespace DNN {
19 
20 template<typename AReal>
22  const TMatrixT<AReal> & A)
23 {
24  size_t m,n;
25  m = A.GetNrows();
26  n = A.GetNcols();
27 
28  for (size_t i = 0; i < m; i++) {
29  for (size_t j = 0; j < n; j++) {
30  AReal sig = 1.0 / (1.0 + std::exp(-A(i,j)));
31  B(i,j) = sig;
32  }
33  }
34 }
35 
36 template<typename AReal>
38  const TMatrixT<AReal> & A)
39 {
40  size_t m,n;
41  m = A.GetNrows();
42  n = A.GetNcols();
43 
44  for (size_t i = 0; i < m; i++) {
45  AReal sum = 0.0;
46  for (size_t j = 0; j < n; j++) {
47  sum += exp(A(i,j));
48  }
49  for (size_t j = 0; j < n; j++) {
50  B(i,j) = exp(A(i,j)) / sum;
51  }
52  }
53 }
54 
55 } // namespace TMVA
56 } // namespace DNN
static double B[]
static long int sum(long int i)
Definition: Factory.cxx:1786
Int_t GetNcols() const
Definition: TMatrixTBase.h:137
static void Sigmoid(TMatrixT< AReal > &B)
static double A[]
TMatrixT.
Definition: TMatrixDfwd.h:24
TMarker * m
Definition: textangle.C:8
Int_t GetNrows() const
Definition: TMatrixTBase.h:134
static void Softmax(TMatrixT< AReal > &YHat, const TMatrixT< AReal > &)
Abstract ClassifierFactory template that handles arbitrary types.
double exp(double)
const Int_t n
Definition: legend1.C:16