Logo ROOT   6.18/05
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
17namespace TMVA {
18namespace DNN {
19
20template<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
36template<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
double exp(double)
static void Softmax(TMatrixT< AReal > &YHat, const TMatrixT< AReal > &)
static void Sigmoid(TMatrixT< AReal > &B)
const Int_t n
Definition: legend1.C:16
static double B[]
static double A[]
create variable transformations
auto * m
Definition: textangle.C:8
static long int sum(long int i)
Definition: Factory.cxx:2258