86 fLocalTrainingTree(0),
88 fValidationFraction(0.5),
100 fLocalTrainingTree(0),
102 fValidationFraction(0.5),
103 fLearningMethod(
"" )
130 if (fMLP)
delete fMLP;
157 std::vector<TString>::iterator
itrVar = (*fInputVars).
begin();
158 std::vector<TString>::iterator
itrVarEnd = (*fInputVars).
end();
159 fMLPBuildOptions =
"";
163 fMLPBuildOptions +=
myVar;
164 fMLPBuildOptions +=
",";
166 fMLPBuildOptions.Chop();
169 fMLPBuildOptions += fHiddenLayer;
170 fMLPBuildOptions +=
"type";
172 Log() << kINFO <<
"Use " << fNcycles <<
" training cycles" <<
Endl;
173 Log() << kINFO <<
"Use configuration (nodes per hidden layer): " << fHiddenLayer <<
Endl;
193 DeclareOptionRef( fNcycles = 200,
"NCycles",
"Number of training cycles" );
194 DeclareOptionRef( fLayerSpec =
"N,N-1",
"HiddenLayers",
"Specification of hidden layer architecture (N stands for number of variables; any integers may also be used)" );
196 DeclareOptionRef( fValidationFraction = 0.5,
"ValidationFraction",
197 "Fraction of events in training tree used for cross validation" );
199 DeclareOptionRef( fLearningMethod =
"Stochastic",
"LearningMethod",
"Learning method" );
200 AddPreDefVal(
TString(
"Stochastic") );
201 AddPreDefVal(
TString(
"Batch") );
202 AddPreDefVal(
TString(
"SteepestDescent") );
203 AddPreDefVal(
TString(
"RibierePolak") );
204 AddPreDefVal(
TString(
"FletcherReeves") );
205 AddPreDefVal(
TString(
"BFGS") );
213 CreateMLPOptions(fLayerSpec);
215 if (IgnoreEventsWithNegWeightsInTraining()) {
216 Log() << kFATAL <<
"Mechanism to ignore events with negative weights in training not available for method"
217 << GetMethodTypeName()
218 <<
" --> please remove \"IgnoreNegWeightsInTraining\" option from booking string."
275 for (
UInt_t i=0; i<GetNvar(); i++) {
276 vArr[i] =
ev->GetValue( i );
278 type = DataInfo().IsSignal(
ev ) ? 1 : 0;
279 weight =
ev->GetWeight();
294 trainList += (
Int_t)(Data()->GetNEvtSigTrain() + (1.0 - fValidationFraction)*Data()->GetNEvtBkgdTrain());
299 Log() << kHEADER <<
"Requirement for training events: \"" <<
trainList <<
"\"" <<
Endl;
300 Log() << kINFO <<
"Requirement for validation events: \"" <<
testList <<
"\"" <<
Endl;
305 if (fMLP) {
delete fMLP; fMLP =
nullptr; }
310 fMLP->SetEventWeight(
"weight" );
315 fLearningMethod.ToLower();
323 Log() << kFATAL <<
"Unknown Learning Method: \"" << fLearningMethod <<
"\"" <<
Endl;
328 fMLP->Train(fNcycles,
"" );
348 fMLP->DumpWeights(
tmpfile.Data() );
353 while (
inf.getline(temp,256)) {
359 dummy = dummy(0,dummy.
First(
' '));
364 data += (dummy +
" ");
381 const TString fname = GetWeightFileDir()+
"/TMlp.nn.weights.temp";
388 fout <<
"#input normalization" << std::endl;
394 fout <<
"#output normalization" << std::endl;
400 fout <<
"#neurons weights" << std::endl;
406 fout <<
"#synapses weights" ;
423 TString vn = DataInfo().GetVariableInfo(
ivar).GetInternalName();
429 if (fMLP) {
delete fMLP; fMLP =
nullptr; }
431 fMLP->LoadWeights(
fname );
441 std::ofstream
fout(
"./TMlp.nn.weights.temp" );
446 Log() << kINFO <<
"Load TMLP weights into " << fMLP <<
Endl;
459 if (fMLP) {
delete fMLP; fMLP =
nullptr; }
462 fMLP->LoadWeights(
"./TMlp.nn.weights.temp" );
477 classFileName = GetWeightFileDir() +
"/" + GetJobName() +
"_" + GetMethodName() +
".class";
482 Log() << kINFO <<
"Creating specific (TMultiLayerPerceptron) standalone response class: " <<
classFileName <<
Endl;
505 Log() <<
"This feed-forward multilayer perceptron neural network is the " <<
Endl;
506 Log() <<
"standard implementation distributed with ROOT (class TMultiLayerPerceptron)." <<
Endl;
508 Log() <<
"Detailed information is available here:" <<
Endl;
509 if (
gConfig().WriteOptionsReference()) {
510 Log() <<
"<a href=\"https://root.cern/doc/master/classTMultiLayerPerceptron.html\">";
511 Log() <<
"https://root.cern/doc/master/classTMultiLayerPerceptron.html</a>" <<
Endl;
513 else Log() <<
"https://root.cern/doc/master/classTMultiLayerPerceptron.html" <<
Endl;
#define REGISTER_METHOD(CLASS)
for example
const Bool_t EnforceNormalization__
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 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 type
const_iterator begin() const
const_iterator end() const
Class that contains all the data information.
Virtual base Class for all MVA method.
This is the TMVA TMultiLayerPerceptron interface class.
void ReadWeightsFromStream(std::istream &istr) override
read weights from stream since the MLP can not read from the stream, we 1st: write the weights to tem...
void MakeClass(const TString &classFileName=TString("")) const override
create reader class for classifier -> overwrites base class function create specific class for TMulti...
void Train(void) override
performs TMlpANN training available learning methods:
void ReadWeightsFromXML(void *wghtnode) override
rebuild temporary textfile from xml weightfile and load this file into MLP
void AddWeightsXMLTo(void *parent) const override
write weights to xml file
void DeclareOptions() override
define the options (their key words) that can be set in the option string
void CreateMLPOptions(TString)
translates options from option string into TMlpANN language
void ProcessOptions() override
builds the neural network as specified by the user
MethodTMlpANN(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="3000:N-1:N-2")
standard constructor
Double_t GetMvaValue(Double_t *err=nullptr, Double_t *errUpper=nullptr) override
calculate the value of the neural net for the current event
void Init(void) override
default initialisations
virtual ~MethodTMlpANN(void)
destructor
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets) override
TMlpANN can handle classification with 2 classes.
void GetHelpMessage() const override
get help message text
void MakeClassSpecific(std::ostream &, const TString &) const override
write specific classifier response nothing to do here - all taken care of by TMultiLayerPerceptron
Singleton class for Global types used by TMVA.
This class describes a neural network.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Ssiz_t First(char c) const
Find first occurrence of a character c.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
A TTree represents a columnar dataset.
create variable transformations
MsgLogger & Endl(MsgLogger &ml)