ROOT
master
Reference Guide
Loading...
Searching...
No Matches
TrainingHistory.cxx
Go to the documentation of this file.
1
/**********************************************************************************
2
* Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
3
* Package: TMVA *
4
* Class : TrainingHistory *
5
* *
6
* *
7
* Description: *
8
* Implementation (see header for description) *
9
* *
10
* Author: *
11
* Joseph McKenna <Joseph.McKenna@cern.ch> - Aarhus, Denmark *
12
* *
13
* Copyright (c) 2019: *
14
* Aarhus, Denmark *
15
* *
16
* Redistribution and use in source and binary forms, with or without *
17
* modification, are permitted according to the terms listed in LICENSE *
18
* (see tmva/doc/LICENSE) *
19
**********************************************************************************/
20
21
/*! \class TMVA::TrainingHistory
22
\ingroup TMVA
23
24
Tracking data from training. Eg, From deep learning record loss for each Epoch
25
26
*/
27
28
29
#include "
TMVA/TrainingHistory.h
"
30
31
#include "
TH1D.h
"
32
33
////////////////////////////////////////////////////////////////////////////////
34
/// constructor
35
36
TMVA::TrainingHistory::TrainingHistory
()
37
{
38
}
39
40
TMVA::TrainingHistory::~TrainingHistory
()
41
{
42
for
(
auto
p
: fHistoryData) {
43
delete
p
;
44
}
45
}
46
47
void
TMVA::TrainingHistory::AddValue
(
TString
Property,
Int_t
stage,
Double_t
value
)
48
{
49
if
(!fHistoryMap.count(Property))
50
{
51
fHistoryMap[Property]=fHistoryData.size();
52
IterationRecord
*
data
=
new
IterationRecord
();
53
fHistoryData.push_back(
data
);
54
}
55
int
iHistory
=fHistoryMap.at(Property);
56
//std::cout<<"HISTORY!"<<"Adding value ("<<Property<<"):"<<stage<<"\t"<<value<<std::endl;
57
fHistoryData.at(
iHistory
)->push_back({stage,
value
});
58
}
59
60
void
TMVA::TrainingHistory::SaveHistory
(
TString
Name)
61
{
62
//if (fHistoryData.empty()) return;
63
for
(
const
auto
&
element
: fHistoryMap ) {
64
TString
property
=
element
.first;
65
Int_t
iHistory
=
element
.second;
66
Int_t
nBins=fHistoryData.at(
iHistory
)->size();
67
Double_t
xMin
=fHistoryData.at(
iHistory
)->front().first;
68
Double_t
xMax
=fHistoryData.at(
iHistory
)->back().first;
69
Double_t
BinSize
=(
xMax
-
xMin
)/(
Double_t
)(nBins-1);
70
TH1D
*
h
=
new
TH1D
(
"TrainingHistory_"
+Name+
"_"
+
property
,
"TrainingHistory_"
+Name+
"_"
+
property
,nBins,
xMin
-0.5*
BinSize
,
xMax
+0.5*
BinSize
);
71
for
(
int
i=0; i<nBins; i++) {
72
h
->AddBinContent(i+1,fHistoryData.at(
iHistory
)->at(i).second);
73
}
74
h
->Print();
75
if
(
h
!=0) {
76
h
->Write();
77
delete
h
;
78
}
79
80
}
81
}
h
#define h(i)
Definition
RSha256.hxx:106
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
p
winID h TVirtualViewer3D TVirtualGLPainter p
Definition
TGWin32VirtualGLProxy.cxx:51
data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Definition
TGWin32VirtualXProxy.cxx:104
value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Definition
TGWin32VirtualXProxy.cxx:142
property
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
Definition
TGWin32VirtualXProxy.cxx:249
TH1D.h
TrainingHistory.h
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TH1D
1-D histogram with a double per channel (see TH1 documentation)
Definition
TH1.h:693
TMVA::TrainingHistory::AddValue
void AddValue(TString Property, Int_t stage, Double_t value)
Definition
TrainingHistory.cxx:47
TMVA::TrainingHistory::IterationRecord
std::vector< std::pair< Int_t, Double_t > > IterationRecord
Definition
TrainingHistory.h:34
TMVA::TrainingHistory::~TrainingHistory
virtual ~TrainingHistory()
Definition
TrainingHistory.cxx:40
TMVA::TrainingHistory::SaveHistory
void SaveHistory(TString Name)
Definition
TrainingHistory.cxx:60
TMVA::TrainingHistory::TrainingHistory
TrainingHistory()
constructor
Definition
TrainingHistory.cxx:36
TString
Basic string class.
Definition
TString.h:139
double
int
tmva
tmva
src
TrainingHistory.cxx
ROOT master - Reference Guide Generated on Sun Mar 2 2025 15:20:36 (GVA Time) using Doxygen 1.10.0