Logo ROOT  
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
24Tracking data from training. Eg, From deep learning record loss for each Epoch
25
26*/
27
28
30
31#include "TH1D.h"
32
33////////////////////////////////////////////////////////////////////////////////
34/// constructor
35
37{
38}
39
41{
42 for (auto p : fHistoryData) {
43 delete p;
44 }
45}
46
48{
49 if (!fHistoryMap.count(Property))
50 {
51 fHistoryMap[Property]=fHistoryData.size();
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
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}
#define h(i)
Definition RSha256.hxx:106
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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
1-D histogram with a double per channel (see TH1 documentation)
Definition TH1.h:670
void AddValue(TString Property, Int_t stage, Double_t value)
std::vector< std::pair< Int_t, Double_t > > IterationRecord
void SaveHistory(TString Name)
Basic string class.
Definition TString.h:139