ROOT
Version master
master
v6.34
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
v6.04
Reference Guide
▼
ROOT
ROOT Reference Documentation
Tutorials
►
Functional Parts
►
Namespaces
►
All Classes
▼
Files
▼
File List
►
bindings
►
core
►
documentation
►
geom
►
graf2d
►
graf3d
►
gui
►
hist
►
io
►
main
►
master
►
math
►
montecarlo
►
net
►
proof
►
roofit
►
sql
▼
tmva
doc
►
pymva
►
rmva
►
sofie
►
sofie_parsers
▼
tmva
►
inc
▼
src
▼
DNN
▼
Architectures
►
Cpu
►
Cuda
►
Cudnn
▼
Reference
ActivationFunctions.hxx
Arithmetic.hxx
DataLoader.cxx
DenoisePropagation.hxx
Dropout.hxx
Initialization.hxx
LossFunctions.hxx
OutputFunctions.hxx
Propagation.hxx
RecurrentPropagation.hxx
Regularization.hxx
TensorDataLoader.cxx
Cpu.cxx
Cuda.cu
Cudnn.cu
Reference.cxx
BDTEventWrapper.cxx
BinarySearchTree.cxx
BinarySearchTreeNode.cxx
BinaryTree.cxx
CCPruner.cxx
CCTreeWrapper.cxx
►
Classification.cxx
ClassifierFactory.cxx
ClassInfo.cxx
Config.cxx
Configurable.cxx
ConvergenceTest.cxx
CostComplexityPruneTool.cxx
CrossEntropy.cxx
CrossValidation.cxx
CvSplit.cxx
DataInputHandler.cxx
DataLoader.cxx
DataSet.cxx
►
DataSetFactory.cxx
DataSetInfo.cxx
DataSetManager.cxx
►
DecisionTree.cxx
DecisionTreeNode.cxx
Envelope.cxx
Event.cxx
ExpectedErrorPruneTool.cxx
►
Factory.cxx
FitterBase.cxx
GeneticAlgorithm.cxx
GeneticFitter.cxx
GeneticGenes.cxx
GeneticPopulation.cxx
GeneticRange.cxx
GiniIndex.cxx
GiniIndexWithLaplace.cxx
HyperParameterOptimisation.cxx
IFitterTarget.cxx
IMethod.cxx
Interval.cxx
►
KDEKernel.cxx
LDA.cxx
LogInterval.cxx
LossFunction.cxx
MCFitter.cxx
MethodANNBase.cxx
►
MethodBase.cxx
MethodBayesClassifier.cxx
MethodBDT.cxx
MethodBoost.cxx
MethodCategory.cxx
MethodCFMlpANN.cxx
►
MethodCFMlpANN_Utils.cxx
MethodCompositeBase.cxx
MethodCrossValidation.cxx
MethodCuts.cxx
►
MethodDL.cxx
►
MethodDNN.cxx
MethodDT.cxx
MethodFDA.cxx
MethodFisher.cxx
MethodHMatrix.cxx
MethodKNN.cxx
MethodLD.cxx
MethodLikelihood.cxx
MethodMLP.cxx
MethodPDEFoam.cxx
MethodPDERS.cxx
MethodPlugins.cxx
MethodRuleFit.cxx
MethodSVM.cxx
►
MethodTMlpANN.cxx
MinuitFitter.cxx
MinuitWrapper.cxx
MisClassificationError.cxx
ModulekNN.cxx
►
MsgLogger.cxx
►
NeuralNet.cxx
Node.cxx
OptimizeConfigParameters.cxx
Option.cxx
OptionMap.cxx
►
PDEFoam.cxx
PDEFoamCell.cxx
PDEFoamDecisionTree.cxx
PDEFoamDecisionTreeDensity.cxx
PDEFoamDensityBase.cxx
PDEFoamDiscriminant.cxx
PDEFoamDiscriminantDensity.cxx
PDEFoamEvent.cxx
PDEFoamEventDensity.cxx
PDEFoamKernelBase.cxx
PDEFoamKernelGauss.cxx
PDEFoamKernelLinN.cxx
PDEFoamKernelTrivial.cxx
PDEFoamMultiTarget.cxx
PDEFoamTarget.cxx
PDEFoamTargetDensity.cxx
PDEFoamVect.cxx
PDF.cxx
QuickMVAProbEstimator.cxx
Ranking.cxx
RBDT.cxx
Reader.cxx
RegressionVariance.cxx
Results.cxx
ResultsClassification.cxx
ResultsMulticlass.cxx
ResultsRegression.cxx
ROCCalc.cxx
►
ROCCurve.cxx
RootFinder.cxx
Rule.cxx
RuleCut.cxx
RuleEnsemble.cxx
RuleFit.cxx
RuleFitAPI.cxx
►
RuleFitParams.cxx
SdivSqrtSplusB.cxx
SeparationBase.cxx
SimulatedAnnealing.cxx
SimulatedAnnealingFitter.cxx
SVEvent.cxx
SVKernelFunction.cxx
SVKernelMatrix.cxx
SVWorkingSet.cxx
TActivation.cxx
TActivationChooser.cxx
TActivationIdentity.cxx
TActivationRadial.cxx
TActivationReLU.cxx
TActivationSigmoid.cxx
TActivationTanh.cxx
Timer.cxx
►
TNeuron.cxx
TNeuronInput.cxx
TNeuronInputAbs.cxx
TNeuronInputChooser.cxx
TNeuronInputSqSum.cxx
TNeuronInputSum.cxx
Tools.cxx
TrainingHistory.cxx
TransformationHandler.cxx
TSpline1.cxx
TSpline2.cxx
►
TSynapse.cxx
►
Types.cxx
VariableDecorrTransform.cxx
VariableGaussTransform.cxx
VariableIdentityTransform.cxx
►
VariableImportance.cxx
VariableInfo.cxx
VariableNormalizeTransform.cxx
VariablePCATransform.cxx
VariableRearrangeTransform.cxx
►
VariableTransform.cxx
►
VariableTransformBase.cxx
VarTransformHandler.cxx
Volume.cxx
►
tmvagui
►
tree
►
tutorials
►
File Members
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
DataLoader.cxx
Go to the documentation of this file.
1
// @(#)root/tmva/tmva/dnn:$Id$
2
// Author: Simon Pfreundschuh 06/06/17
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
// Specializations of Copy functions for the DataLoader //
14
// specialized for the reference architecture. //
15
/////////////////////////////////////////////////////////////
16
17
#include "
TMVA/DNN/Architectures/Reference.h
"
18
#include "
TMVA/DataSetInfo.h
"
19
20
namespace
TMVA
{
21
namespace
DNN {
22
23
//______________________________________________________________________________
24
template
<>
25
void
TDataLoader<MatrixInput_t, TReference<Real_t>
>::CopyInput(
TMatrixT<Real_t>
&
matrix
,
IndexIterator_t
sampleIterator
)
26
{
27
const
TMatrixT<Real_t>
&
input
= std::get<0>(fData);
28
Int_t
m
=
matrix
.GetNrows();
29
Int_t
n
=
input
.GetNcols();
30
31
for
(
Int_t
i = 0; i <
m
; i++) {
32
Int_t
sampleIndex
= *
sampleIterator
;
33
for
(
Int_t
j
= 0;
j
<
n
;
j
++) {
34
matrix
(i,
j
) =
static_cast<
Real_t
>
(
input
(
sampleIndex
,
j
));
35
}
36
sampleIterator
++;
37
}
38
}
39
40
//______________________________________________________________________________
41
template
<>
42
void
TDataLoader<MatrixInput_t, TReference<Real_t>
>::CopyOutput(
TMatrixT<Real_t>
&
matrix
,
43
IndexIterator_t
sampleIterator
)
44
{
45
const
TMatrixT<Real_t>
&
output
= std::get<1>(fData);
46
Int_t
m
=
matrix
.GetNrows();
47
Int_t
n
=
output
.GetNcols();
48
49
for
(
Int_t
i = 0; i <
m
; i++) {
50
Int_t
sampleIndex
= *
sampleIterator
;
51
for
(
Int_t
j
= 0;
j
<
n
;
j
++) {
52
matrix
(i,
j
) =
static_cast<
Real_t
>
(
output
(
sampleIndex
,
j
));
53
}
54
sampleIterator
++;
55
}
56
}
57
58
//______________________________________________________________________________
59
template
<>
60
void
TDataLoader<MatrixInput_t, TReference<Real_t>
>::CopyWeights(
TMatrixT<Real_t>
&
matrix
,
61
IndexIterator_t
sampleIterator
)
62
{
63
const
TMatrixT<Real_t>
&weights = std::get<2>(fData);
64
Int_t
m
=
matrix
.GetNrows();
65
66
for
(
Int_t
i = 0; i <
m
; i++) {
67
Int_t
sampleIndex
= *
sampleIterator
;
68
matrix
(i, 0) =
static_cast<
Real_t
>
(weights(
sampleIndex
, 0));
69
sampleIterator
++;
70
}
71
}
72
73
//______________________________________________________________________________
74
template
<>
75
void
TDataLoader<MatrixInput_t, TReference<Double_t>
>::CopyInput(
TMatrixT<Double_t>
&
matrix
,
76
IndexIterator_t
sampleIterator
)
77
{
78
const
TMatrixT<Double_t>
&
input
= std::get<0>(fData);
79
Int_t
m
=
matrix
.GetNrows();
80
Int_t
n
=
input
.GetNcols();
81
82
for
(
Int_t
i = 0; i <
m
; i++) {
83
Int_t
sampleIndex
= *
sampleIterator
;
84
for
(
Int_t
j
= 0;
j
<
n
;
j
++) {
85
matrix
(i,
j
) =
static_cast<
Double_t
>
(
input
(
sampleIndex
,
j
));
86
}
87
sampleIterator
++;
88
}
89
}
90
91
//______________________________________________________________________________
92
template
<>
93
void
TDataLoader<MatrixInput_t, TReference<Double_t>
>::CopyOutput(
TMatrixT<Double_t>
&
matrix
,
94
IndexIterator_t
sampleIterator
)
95
{
96
const
TMatrixT<Double_t>
&
output
= std::get<1>(fData);
97
Int_t
m
=
matrix
.GetNrows();
98
Int_t
n
=
output
.GetNcols();
99
100
for
(
Int_t
i = 0; i <
m
; i++) {
101
Int_t
sampleIndex
= *
sampleIterator
;
102
for
(
Int_t
j
= 0;
j
<
n
;
j
++) {
103
matrix
(i,
j
) =
static_cast<
Double_t
>
(
output
(
sampleIndex
,
j
));
104
}
105
sampleIterator
++;
106
}
107
}
108
109
//______________________________________________________________________________
110
template
<>
111
void
TDataLoader<MatrixInput_t, TReference<Double_t>
>::CopyWeights(
TMatrixT<Double_t>
&
matrix
,
112
IndexIterator_t
sampleIterator
)
113
{
114
const
TMatrixT<Double_t>
&
output
= std::get<2>(fData);
115
Int_t
m
=
matrix
.GetNrows();
116
117
for
(
Int_t
i = 0; i <
m
; i++) {
118
Int_t
sampleIndex
= *
sampleIterator
;
119
matrix
(i, 0) =
static_cast<
Double_t
>
(
output
(
sampleIndex
, 0));
120
sampleIterator
++;
121
}
122
}
123
124
//______________________________________________________________________________
125
template
<>
126
void
TDataLoader<TMVAInput_t, TReference<Real_t>
>::CopyInput(
TMatrixT<Real_t>
&
matrix
,
IndexIterator_t
sampleIterator
)
127
{
128
// short-circuit on empty
129
if
(std::get<0>(fData).empty())
130
return
;
131
Event
*
event
=
nullptr
;
132
133
Int_t
m
=
matrix
.GetNrows();
134
Int_t
n
=
matrix
.GetNcols();
135
136
// Copy input variables.
137
138
for
(
Int_t
i = 0; i <
m
; i++) {
139
Int_t
sampleIndex
= *
sampleIterator
++;
140
event
= std::get<0>(fData)[
sampleIndex
];
141
for
(
Int_t
j
= 0;
j
<
n
;
j
++) {
142
matrix
(i,
j
) =
event
->GetValue(
j
);
143
}
144
}
145
}
146
147
//______________________________________________________________________________
148
template
<>
149
void
TDataLoader<TMVAInput_t, TReference<Real_t>
>::CopyOutput(
TMatrixT<Real_t>
&
matrix
,
IndexIterator_t
sampleIterator
)
150
{
151
// short-circuit on empty
152
if
(std::get<0>(fData).empty())
153
return
;
154
Event
*
event
=
nullptr
;
155
const
DataSetInfo
&
info
= std::get<1>(fData);
156
Int_t
m
=
matrix
.GetNrows();
157
Int_t
n
=
matrix
.GetNcols();
158
159
for
(
Int_t
i = 0; i <
m
; i++) {
160
Int_t
sampleIndex
= *
sampleIterator
++;
161
event
= std::get<0>(fData)[
sampleIndex
];
162
for
(
Int_t
j
= 0;
j
<
n
;
j
++) {
163
// Classification
164
if
(event->GetNTargets() == 0) {
165
if
(
n
== 1) {
166
// Binary.
167
matrix
(i,
j
) = (
info
.IsSignal(event)) ? 1.0 : 0.0;
168
}
else
{
169
// Multiclass.
170
matrix
(i,
j
) = 0.0;
171
if
(
j
==
static_cast<
Int_t
>
(event->GetClass())) {
172
matrix
(i,
j
) = 1.0;
173
}
174
}
175
}
else
{
176
matrix
(i,
j
) =
static_cast<
Real_t
>
(
event
->GetTarget(
j
));
177
}
178
}
179
}
180
}
181
182
//______________________________________________________________________________
183
template
<>
184
void
TDataLoader<TMVAInput_t, TReference<Real_t>
>::CopyWeights(
TMatrixT<Real_t>
&
matrix
,
IndexIterator_t
sampleIterator
)
185
{
186
// short-circuit on empty
187
if
(std::get<0>(fData).empty())
188
return
;
189
Event
*
event
=
nullptr
;
190
for
(
Int_t
i = 0; i <
matrix
.GetNrows(); i++) {
191
Int_t
sampleIndex
= *
sampleIterator
++;
192
event
= std::get<0>(fData)[
sampleIndex
];
193
matrix
(i, 0) =
event
->GetWeight();
194
}
195
}
196
197
//______________________________________________________________________________
198
template
<>
199
void
TDataLoader<TMVAInput_t, TReference<Double_t>
>::CopyInput(
TMatrixT<Double_t>
&
matrix
,
200
IndexIterator_t
sampleIterator
)
201
{
202
// short-circuit on empty
203
if
(std::get<0>(fData).empty())
204
return
;
205
Event
*
event
=
nullptr
;
206
Int_t
m
=
matrix
.GetNrows();
207
208
// Copy input variables.
209
210
for
(
Int_t
i = 0; i <
m
; i++) {
211
Int_t
sampleIndex
= *
sampleIterator
++;
212
event
= std::get<0>(fData)[
sampleIndex
];
213
for
(
Int_t
j
= 0;
j < static_cast<Int_t>
(event ? event->GetNVariables() : 0);
j
++) {
214
matrix
(i,
j
) =
event
->GetValue(
j
);
215
}
216
}
217
}
218
219
//______________________________________________________________________________
220
template
<>
221
void
TDataLoader<TMVAInput_t, TReference<Double_t>
>::CopyOutput(
TMatrixT<Double_t>
&
matrix
,
222
IndexIterator_t
sampleIterator
)
223
{
224
Event
*
event
=
nullptr
;
225
const
DataSetInfo
&
info
= std::get<1>(fData);
226
Int_t
m
=
matrix
.GetNrows();
227
Int_t
n
=
matrix
.GetNcols();
228
229
for
(
Int_t
i = 0; i <
m
; i++) {
230
Int_t
sampleIndex
= *
sampleIterator
++;
231
event
= std::get<0>(fData)[
sampleIndex
];
232
for
(
Int_t
j
= 0;
j
<
n
;
j
++) {
233
// Classification
234
if
(event->GetNTargets() == 0) {
235
if
(
n
== 1) {
236
// Binary.
237
matrix
(i,
j
) = (
info
.IsSignal(event)) ? 1.0 : 0.0;
238
}
else
{
239
// Multiclass.
240
matrix
(i,
j
) = 0.0;
241
if
(
j
==
static_cast<
Int_t
>
(event->GetClass())) {
242
matrix
(i,
j
) = 1.0;
243
}
244
}
245
}
else
{
246
matrix
(i,
j
) =
static_cast<
Real_t
>
(
event
->GetTarget(
j
));
247
}
248
}
249
}
250
}
251
252
//______________________________________________________________________________
253
template
<>
254
void
TDataLoader<TMVAInput_t, TReference<Double_t>
>::CopyWeights(
TMatrixT<Double_t>
&
matrix
,
255
IndexIterator_t
sampleIterator
)
256
{
257
Event
*
event
=
nullptr
;
258
259
for
(
Int_t
i = 0; i <
matrix
.GetNrows(); i++) {
260
Int_t
sampleIndex
= *
sampleIterator
++;
261
event
= std::get<0>(fData)[
sampleIndex
];
262
matrix
(i, 0) =
event
->GetWeight();
263
}
264
}
265
266
// Explicit instantiations.
267
template
class
TDataLoader<MatrixInput_t, TReference<Real_t>
>;
268
template
class
TDataLoader<TMVAInput_t, TReference<Real_t>
>;
269
template
class
TDataLoader<MatrixInput_t, TReference<Double_t>
>;
270
template
class
TDataLoader<TMVAInput_t, TReference<Double_t>
>;
271
272
}
// namespace DNN
273
}
// namespace TMVA
DataSetInfo.h
Reference.h
Real_t
float Real_t
Definition
RtypesCore.h:68
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Definition
TGWin32VirtualXProxy.cxx:142
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
ROOT::Internal::TypedIter
Definition
RRangeCast.hxx:78
TMVA::DataSetInfo
Class that contains all the data information.
Definition
DataSetInfo.h:62
TMVA::Event
Definition
Event.h:51
double
int
n
const Int_t n
Definition
legend1.C:16
TMVA
create variable transformations
Definition
GeneticMinimizer.h:22
m
TMarker m
Definition
textangle.C:8
output
static void output()
tmva
tmva
src
DNN
Architectures
Reference
DataLoader.cxx
ROOT master - Reference Guide Generated on Wed Feb 12 2025 04:28:12 (GVA Time) using Doxygen 1.10.0