ROOT
Version v6.32
master
v6.34
Reference Guide
▼
ROOT
ROOT Reference Documentation
Tutorials
►
Functional Parts
►
Namespaces
►
All Classes
▼
Files
▼
File List
►
bindings
►
core
►
documentation
►
geom
►
graf2d
►
graf3d
►
gui
►
hist
►
html
►
io
►
main
►
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
►
v6-32-00-patches
►
File Members
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
TensorDataLoader.cxx
Go to the documentation of this file.
1
// @(#)root/tmva/tmva/dnn:$Id$
2
// Author: Vladimir Ilievski
3
4
/**********************************************************************************
5
* Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6
* Package: TMVA *
7
* Class : TTensorDataLoader *
8
* *
9
* *
10
* Description: *
11
* Specialization of the Tensor Data Loader Class *
12
* *
13
* Authors (alphabetical): *
14
* Vladimir Ilievski <ilievski.vladimir@live.com> - CERN, Switzerland *
15
* *
16
* Copyright (c) 2005-2015: *
17
* CERN, Switzerland *
18
* U. of Victoria, Canada *
19
* MPI-K Heidelberg, Germany *
20
* U. of Bonn, Germany *
21
* *
22
* Redistribution and use in source and binary forms, with or without *
23
* modification, are permitted according to the terms listed in LICENSE *
24
* (see tmva/doc/LICENSE) *
25
**********************************************************************************/
26
27
///////////////////////////////////////////////////////////////////
28
// Specializations of Copy functions for the TensorDataLoader //
29
// specialized for the reference architecture. //
30
///////////////////////////////////////////////////////////////////
31
32
#include "
TMVA/DNN/Architectures/Reference.h
"
33
#include "
TMVA/DataSetInfo.h
"
34
35
namespace
TMVA
{
36
namespace
DNN {
37
38
//______________________________________________________________________________
39
template
<>
40
void
TTensorDataLoader<TensorInput, TReference<Real_t>
>::CopyTensorInput(std::vector<
TMatrixT<Real_t>
> &
tensor
,
41
IndexIterator_t
sampleIterator
)
42
{
43
const
std::vector<TMatrixT<Double_t>> &
linputTensor
= std::get<0>(fData);
44
45
if
(fBatchDepth == 1) {
46
for
(
size_t
i = 0; i < fBatchHeight; i++) {
47
size_t
sampleIndex
= *
sampleIterator
;
48
for
(
size_t
j
= 0;
j
< fBatchWidth;
j
++) {
49
tensor
[0](i,
j
) =
static_cast<
Real_t
>
(
linputTensor
[0](
sampleIndex
,
j
));
50
}
51
sampleIterator
++;
52
}
53
}
else
{
54
for
(
size_t
i = 0; i < fBatchDepth; i++) {
55
size_t
sampleIndex
= *
sampleIterator
;
56
for
(
size_t
j
= 0;
j
< fBatchHeight;
j
++) {
57
for
(
size_t
k = 0; k < fBatchWidth; k++) {
58
tensor
[i](
j
, k) =
static_cast<
Real_t
>
(
linputTensor
[
sampleIndex
](
j
, k));
59
}
60
}
61
sampleIterator
++;
62
}
63
}
64
}
65
66
//______________________________________________________________________________
67
template
<>
68
void
TTensorDataLoader<TensorInput, TReference<Real_t>
>::CopyTensorOutput(
TMatrixT<Real_t>
&
matrix
,
69
IndexIterator_t
sampleIterator
)
70
{
71
const
TMatrixT<Double_t>
&
loutputMatrix
= std::get<1>(fData);
72
size_t
n
=
loutputMatrix
.GetNcols();
73
74
for
(
size_t
i = 0; i < fInputShape[0]; i++) {
75
size_t
sampleIndex
= *
sampleIterator
;
76
for
(
size_t
j
= 0;
j
<
n
;
j
++) {
77
matrix
(i,
j
) =
static_cast<
Real_t
>
(
loutputMatrix
(
sampleIndex
,
j
));
78
}
79
80
sampleIterator
++;
81
}
82
}
83
84
//______________________________________________________________________________
85
template
<>
86
void
TTensorDataLoader<TensorInput, TReference<Real_t>
>::CopyTensorWeights(
TMatrixT<Real_t>
&
matrix
,
87
IndexIterator_t
sampleIterator
)
88
{
89
const
TMatrixT<Double_t>
&
lweightMatrix
= std::get<2>(fData);
90
91
for
(
size_t
i = 0; i < fInputShape[0]; i++) {
92
size_t
sampleIndex
= *
sampleIterator
;
93
matrix
(i, 0) =
static_cast<
Real_t
>
(
lweightMatrix
(
sampleIndex
, 0));
94
sampleIterator
++;
95
}
96
}
97
98
//______________________________________________________________________________
99
template
<>
100
void
TTensorDataLoader<TensorInput, TReference<Double_t>
>::CopyTensorInput(std::vector<
TMatrixT<Double_t>
> &
tensor
,
101
IndexIterator_t
sampleIterator
)
102
{
103
const
std::vector<TMatrixT<Double_t>> &
linputTensor
= std::get<0>(fData);
104
105
if
(fBatchDepth == 1) {
106
for
(
size_t
i = 0; i < fBatchHeight; i++) {
107
size_t
sampleIndex
= *
sampleIterator
;
108
for
(
size_t
j
= 0;
j
< fBatchWidth;
j
++) {
109
tensor
[0](i,
j
) =
linputTensor
[0](
sampleIndex
,
j
);
110
}
111
sampleIterator
++;
112
}
113
}
else
{
114
for
(
size_t
i = 0; i < fBatchDepth; i++) {
115
size_t
sampleIndex
= *
sampleIterator
;
116
for
(
size_t
j
= 0;
j
< fBatchHeight;
j
++) {
117
for
(
size_t
k = 0; k < fBatchWidth; k++) {
118
tensor
[i](
j
, k) =
linputTensor
[
sampleIndex
](
j
, k);
119
}
120
}
121
sampleIterator
++;
122
}
123
}
124
}
125
126
//______________________________________________________________________________
127
template
<>
128
void
TTensorDataLoader<TensorInput, TReference<Double_t>
>::CopyTensorOutput(
TMatrixT<Double_t>
&
matrix
,
129
IndexIterator_t
sampleIterator
)
130
{
131
const
TMatrixT<Double_t>
&
loutputMatrix
= std::get<1>(fData);
132
size_t
n
=
loutputMatrix
.GetNcols();
133
134
for
(
size_t
i = 0; i < fInputShape[0]; i++) {
135
size_t
sampleIndex
= *
sampleIterator
;
136
for
(
size_t
j
= 0;
j
<
n
;
j
++) {
137
matrix
(i,
j
) =
loutputMatrix
(
sampleIndex
,
j
);
138
}
139
140
sampleIterator
++;
141
}
142
}
143
144
//______________________________________________________________________________
145
template
<>
146
void
TTensorDataLoader<TensorInput, TReference<Double_t>
>::CopyTensorWeights(
TMatrixT<Double_t>
&
matrix
,
147
IndexIterator_t
sampleIterator
)
148
{
149
const
TMatrixT<Double_t>
&
lweightMatrix
= std::get<2>(fData);
150
151
for
(
size_t
i = 0; i < fInputShape[0]; i++) {
152
size_t
sampleIndex
= *
sampleIterator
;
153
matrix
(i, 0) =
lweightMatrix
(
sampleIndex
, 0);
154
sampleIterator
++;
155
}
156
}
157
158
//______________________________________________________________________________
159
template
<>
160
void
TTensorDataLoader<TMVAInput_t, TReference<Real_t>
>::CopyTensorInput(std::vector<
TMatrixT<Real_t>
> &
tensor
,
161
IndexIterator_t
sampleIterator
)
162
{
163
// one event, one example in the batch
164
Event
*
event
= std::get<0>(fData)[0];
165
166
if
(fBatchDepth == 1) {
167
for
(
size_t
i = 0; i < fBatchHeight; i++) {
168
size_t
sampleIndex
= *
sampleIterator
;
169
for
(
size_t
j
= 0;
j
< fBatchWidth;
j
++) {
170
event
= std::get<0>(fData)[
sampleIndex
];
171
tensor
[0](i,
j
) =
static_cast<
Real_t
>
(event->GetValue(
j
));
172
}
173
sampleIterator
++;
174
}
175
}
else
{
176
for
(
size_t
i = 0; i < fBatchDepth; i++) {
177
size_t
sampleIndex
= *
sampleIterator
;
178
for
(
size_t
j
= 0;
j
< fBatchHeight;
j
++) {
179
for
(
size_t
k = 0; k < fBatchWidth; k++) {
180
event
= std::get<0>(fData)[
sampleIndex
];
181
tensor
[i](
j
, k) =
static_cast<
Real_t
>
(event->GetValue(
j
* fBatchWidth + k));
182
}
183
}
184
sampleIterator
++;
185
}
186
}
187
}
188
189
//______________________________________________________________________________
190
template
<>
191
void
TTensorDataLoader<TMVAInput_t, TReference<Real_t>
>::CopyTensorOutput(
TMatrixT<Real_t>
&
matrix
,
192
IndexIterator_t
sampleIterator
)
193
{
194
const
DataSetInfo
&
info
= std::get<1>(fData);
195
Int_t
n
=
matrix
.GetNcols();
196
197
for
(
size_t
i = 0; i < fInputShape[0]; i++) {
198
size_t
sampleIndex
= *
sampleIterator
++;
199
Event
*
event
= std::get<0>(fData)[
sampleIndex
];
200
201
for
(
Int_t
j
= 0;
j
<
n
;
j
++) {
202
if
(event->GetNTargets() == 0) {
203
if
(
n
== 1) {
204
matrix
(i,
j
) = (
info
.IsSignal(event)) ? 1.0 : 0.0;
205
}
else
{
206
matrix
(i,
j
) = 0.0;
207
if
(
j
== (
Int_t
)event->GetClass()) {
208
matrix
(i,
j
) = 1.0;
209
}
210
}
211
}
else
{
212
matrix
(i,
j
) =
static_cast<
Real_t
>
(
event
->GetTarget(
j
));
213
}
214
}
215
}
216
}
217
218
//______________________________________________________________________________
219
template
<>
220
void
TTensorDataLoader<TMVAInput_t, TReference<Real_t>
>::CopyTensorWeights(
TMatrixT<Real_t>
&
matrix
,
221
IndexIterator_t
sampleIterator
)
222
{
223
for
(
size_t
i = 0; i < fInputShape[0]; i++) {
224
size_t
sampleIndex
= *
sampleIterator
++;
225
Event
*
event
= std::get<0>(fData)[
sampleIndex
];
226
matrix
(i, 0) =
static_cast<
Real_t
>
(
event
->GetWeight());
227
}
228
}
229
230
//______________________________________________________________________________
231
template
<>
232
void
TTensorDataLoader<TMVAInput_t, TReference<Double_t>
>::CopyTensorInput(std::vector<
TMatrixT<Double_t>
> &
tensor
,
233
IndexIterator_t
sampleIterator
)
234
{
235
// one event, one example in the batch
236
Event
*
event
= std::get<0>(fData)[0];
237
238
if
(fBatchDepth == 1) {
239
for
(
size_t
i = 0; i < fBatchHeight; i++) {
240
size_t
sampleIndex
= *
sampleIterator
;
241
for
(
size_t
j
= 0;
j
< fBatchWidth;
j
++) {
242
event
= std::get<0>(fData)[
sampleIndex
];
243
tensor
[0](i,
j
) = event->GetValue(
j
);
244
}
245
sampleIterator
++;
246
}
247
}
else
{
248
for
(
size_t
i = 0; i < fBatchDepth; i++) {
249
size_t
sampleIndex
= *
sampleIterator
;
250
for
(
size_t
j
= 0;
j
< fBatchHeight;
j
++) {
251
for
(
size_t
k = 0; k < fBatchWidth; k++) {
252
event
= std::get<0>(fData)[
sampleIndex
];
253
tensor
[i](
j
, k) = event->GetValue(
j
* fBatchWidth + k);
254
}
255
}
256
sampleIterator
++;
257
}
258
}
259
}
260
261
//______________________________________________________________________________
262
template
<>
263
void
TTensorDataLoader<TMVAInput_t, TReference<Double_t>
>::CopyTensorOutput(
TMatrixT<Double_t>
&
matrix
,
264
IndexIterator_t
sampleIterator
)
265
{
266
const
DataSetInfo
&
info
= std::get<1>(fData);
267
Int_t
n
=
matrix
.GetNcols();
268
269
for
(
size_t
i = 0; i < fInputShape[0]; i++) {
270
size_t
sampleIndex
= *
sampleIterator
++;
271
Event
*
event
= std::get<0>(fData)[
sampleIndex
];
272
273
for
(
Int_t
j
= 0;
j
<
n
;
j
++) {
274
if
(event->GetNTargets() == 0) {
275
if
(
n
== 1) {
276
matrix
(i,
j
) = (
info
.IsSignal(event)) ? 1.0 : 0.0;
277
}
else
{
278
matrix
(i,
j
) = 0.0;
279
if
(
j
== (
Int_t
)event->GetClass()) {
280
matrix
(i,
j
) = 1.0;
281
}
282
}
283
}
else
{
284
matrix
(i,
j
) =
event
->GetTarget(
j
);
285
}
286
}
287
}
288
}
289
290
//______________________________________________________________________________
291
template
<>
292
void
TTensorDataLoader<TMVAInput_t, TReference<Double_t>
>::CopyTensorWeights(
TMatrixT<Double_t>
&
matrix
,
293
IndexIterator_t
sampleIterator
)
294
{
295
for
(
size_t
i = 0; i < fInputShape[0]; i++) {
296
size_t
sampleIndex
= *
sampleIterator
++;
297
Event
*
event
= std::get<0>(fData)[
sampleIndex
];
298
matrix
(i, 0) =
event
->
GetWeight
();
299
}
300
}
301
302
}
// namespace DNN
303
}
// 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
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
TMVA::Event::GetWeight
Double_t GetWeight() const
return the event weight - depending on whether the flag IgnoreNegWeightsInTraining is or not.
Definition
Event.cxx:389
int
n
const Int_t n
Definition
legend1.C:16
TMVA
create variable transformations
Definition
GeneticMinimizer.h:22
tmva
tmva
src
DNN
Architectures
Reference
TensorDataLoader.cxx
ROOT v6-32 - Reference Guide Generated on Wed Mar 26 2025 04:43:14 (GVA Time) using Doxygen 1.10.0