25 template <
typename AFloat_t>
28 template<
typename AFloat>
31 if (!fgRandomGen) fgRandomGen =
new TRandom3();
32 fgRandomGen->SetSeed(seed);
34 template<
typename AFloat>
37 if (!fgRandomGen) fgRandomGen =
new TRandom3(0);
42 template<
typename AFloat>
49 TRandom & rand = GetRandomGenerator();
53 for (
size_t i = 0; i <
m; i++) {
54 for (
size_t j = 0; j <
n; j++) {
55 A(i,j) = rand.
Gaus(0.0, sigma);
61 template<
typename AFloat>
68 TRandom & rand = GetRandomGenerator();
70 AFloat range =
sqrt(2.0 / ((AFloat) n));
72 for (
size_t i = 0; i <
m; i++) {
73 for (
size_t j = 0; j <
n; j++) {
74 A(i,j) = rand.
Uniform(-range, range);
84 template<
typename AFloat>
91 TRandom & rand = GetRandomGenerator();
93 AFloat
sigma =
sqrt(2.0 /( ((AFloat) n) + ((AFloat) m)) );
95 for (
size_t i = 0; i <
m; i++) {
96 for (
size_t j = 0; j <
n; j++) {
97 AFloat value = rand.
Gaus(0.0, sigma);
98 if ( std::abs(value) > 2*sigma)
continue;
99 A(i,j) = rand.
Gaus(0.0, sigma);
109 template<
typename AFloat>
116 TRandom & rand = GetRandomGenerator();
118 AFloat range =
sqrt(6.0 /( ((AFloat) n) + ((AFloat) m)) );
120 for (
size_t i = 0; i <
m; i++) {
121 for (
size_t j = 0; j <
n; j++) {
122 A(i,j) = rand.
Uniform(-range, range);
128 template<
typename AFloat>
135 for (
size_t i = 0; i <
m; i++) {
136 for (
size_t j = 0; j <
n ; j++) {
147 template<
typename AFloat>
154 for (
size_t i = 0; i <
m; i++) {
155 for (
size_t j = 0; j <
n ; j++) {
Random number generator class based on M.
static void InitializeGlorotNormal(TCpuMatrix< Scalar_t > &A)
Truncated normal initialization (Glorot, called also Xavier normal) The values are sample with a norm...
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...
static void InitializeIdentity(TCpuMatrix< Scalar_t > &A)
static TRandom * fgRandomGen
static void InitializeUniform(TCpuMatrix< Scalar_t > &A)
static void InitializeGauss(TCpuMatrix< Scalar_t > &A)
This is the base class for the ROOT Random number generators.
static void SetRandomSeed(size_t seed)
static TRandom & GetRandomGenerator()
static void InitializeZero(TCpuMatrix< Scalar_t > &A)
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Abstract ClassifierFactory template that handles arbitrary types.
static void InitializeGlorotUniform(TCpuMatrix< Scalar_t > &A)
Sample from a uniform distribution in range [ -lim,+lim] where lim = sqrt(6/N_in+N_out).