Logo ROOT   6.07/09
Reference Guide
Initialization.cxx
Go to the documentation of this file.
1 // @(#)root/tmva/tmva/dnn:$Id$
2 // Author: Simon Pfreundschuh 10/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  // Implementation of the initialization functions for the reference //
14  // implementation. //
15  //////////////////////////////////////////////////////////////////////
16 
17 #include "TRandom.h"
19 
20 namespace TMVA
21 {
22 namespace DNN
23 {
24 
25 //______________________________________________________________________________
26 template<typename Real_t>
28 {
29  size_t m,n;
30  m = A.GetNrows();
31  n = A.GetNcols();
32 
33  TRandom rand(time(nullptr));
34 
35  Real_t sigma = sqrt(2.0 / ((Real_t) n));
36 
37  for (size_t i = 0; i < m; i++) {
38  for (size_t j = 0; j < n; j++) {
39  A(i,j) = rand.Gaus(0.0, sigma);
40  }
41  }
42 }
43 
44 //______________________________________________________________________________
45 template<typename Real_t>
47 {
48  size_t m,n;
49  m = A.GetNrows();
50  n = A.GetNcols();
51 
52  TRandom rand(time(nullptr));
53 
54  Real_t range = sqrt(2.0 / ((Real_t) n));
55 
56  for (size_t i = 0; i < m; i++) {
57  for (size_t j = 0; j < n; j++) {
58  A(i,j) = rand.Uniform(-range, range);
59  }
60  }
61 }
62 
63 //______________________________________________________________________________
64 template<typename Real_t>
66 {
67  size_t m,n;
68  m = A.GetNrows();
69  n = A.GetNcols();
70 
71  for (size_t i = 0; i < m; i++) {
72  for (size_t j = 0; j < n; j++) {
73  A(i,j) = 0.0;
74  }
75 
76  if (i < n) {
77  A(i,i) = 1.0;
78  }
79  }
80 }
81 
82 template<typename Real_t>
84 {
85  size_t m,n;
86  m = A.GetNrows();
87  n = A.GetNcols();
88 
89  for (size_t i = 0; i < m ; i++) {
90  for (size_t j = 0; j < n ; j++) {
91  A(i,j) = 0.0;
92  }
93  }
94 }
95 
96 } // namespace DNN
97 } // namespace TMVA
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:235
static void InitializeUniform(TMatrixT< Real_t > &A)
static double A[]
TMatrixT.
Definition: TMatrixDfwd.h:24
double sqrt(double)
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:31
const Double_t sigma
Int_t GetNrows() const
Definition: TMatrixTBase.h:134
TMarker * m
Definition: textangle.C:8
static void InitializeZero(TMatrixT< Real_t > &A)
Int_t GetNcols() const
Definition: TMatrixTBase.h:137
static void InitializeIdentity(TMatrixT< Real_t > &A)
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Definition: TRandom.cxx:606
float Real_t
Definition: RtypesCore.h:64
Abstract ClassifierFactory template that handles arbitrary types.
static void InitializeGauss(TMatrixT< Real_t > &A)
const Int_t n
Definition: legend1.C:16