88using std::stringstream;
189 Int_t currentHiddenLayer = 1;
191 while(layerSpec.
Length()>0) {
193 if (layerSpec.
First(
',')<0) {
198 sToAdd = layerSpec(0,layerSpec.
First(
','));
199 layerSpec = layerSpec(layerSpec.
First(
',')+1,layerSpec.
Length());
203 nNodes += atoi(sToAdd);
204 fNodes[currentHiddenLayer++] = nNodes;
211 Log() << kFATAL <<
"Mechanism to ignore events with negative weights in training not yet available for method: "
213 <<
" --> please remove \"IgnoreNegWeightsInTraining\" option from booking string."
217 Log() << kINFO <<
"Use configuration (nodes per layer): in=";
224 Int_t nEvtTrain =
Data()->GetNTrainingEvents();
231 fClass =
new std::vector<Int_t>( nEvtTrain );
236 for (
Int_t ievt=0; ievt<nEvtTrain; ievt++) {
240 (*fClass)[ievt] =
DataInfo().IsSignal(ev) ? 1 : 2;
243 for (ivar=0; ivar<
GetNvar(); ivar++) {
244 (*fData)( ievt, ivar ) = ev->
GetValue(ivar);
288 Int_t ntrain(
Data()->GetNTrainingEvents());
303 for (
Int_t layer=0; layer<nlayers; layer++)
308 Train_nn( &dumDat, &dumDat, &ntrain, &ntest, &
nvar, &nlayers, nodes, &ncycles );
310 Log() << kWARNING <<
"<Train> sorry CFMlpANN does not run on Windows" <<
Endl;
328 std::vector<Double_t> inputVec(
GetNvar() );
332 if (!isOK)
Log() << kFATAL <<
"EvalANN returns (!isOK) for event " <<
Endl;
347 for (
UInt_t ivar=0; ivar<
GetNvar(); ivar++) xeev[ivar] = inVar[ivar];
353 if (
fVarn_1.xmax[jvar] < xeev[jvar]) xeev[jvar] =
fVarn_1.xmax[jvar];
354 if (
fVarn_1.xmin[jvar] > xeev[jvar]) xeev[jvar] =
fVarn_1.xmin[jvar];
360 xeev[jvar] = xeev[jvar] - ((
fVarn_1.xmax[jvar] +
fVarn_1.xmin[jvar])/2);
361 xeev[jvar] = xeev[jvar] / ((
fVarn_1.xmax[jvar] -
fVarn_1.xmin[jvar])/2);
379 for (
Int_t ivar=0; ivar<
fNeur_1.neuron[0]; ivar++)
fYNN[0][ivar] = xeev[ivar];
402 else if (u/
fDel_1.temp[
i] < -170)
f = -1;
405 f = (1 - yy)/(1 + yy);
423 Log() << kFATAL <<
"<ReadWeightsFromFile> mismatch in number of variables" <<
Endl;
427 Log() << kFATAL <<
"<ReadWeightsFromFile> mismatch in number of classes" <<
Endl;
431 Log() << kFATAL <<
"<ReadWeightsFromStream> reached EOF prematurely " <<
Endl;
455 char* dumchar =
new char[
nchar];
467 for (
Int_t k=1; k<=kk; k++) {
468 Int_t jmin = 10*k - 9;
471 for (
Int_t j=jmin; j<=jmax; j++) {
475 for (
Int_t j=jmin; j<=jmax; j++) {
480 istr.getline( dumchar,
nchar );
487 istr.getline( dumchar,
nchar );
488 istr.getline( dumchar,
nchar );
490 istr >>
fDel_1.temp[layer];
495 Log() << kFATAL <<
"<ReadWeightsFromFile> mismatch in zeroth layer:"
517 Log() << kFATAL <<
"ERROR in MethodCFMlpANN_DataInterface zero pointer xpg" <<
Endl;
520 Log() << kFATAL <<
"ERROR in MethodCFMlpANN_DataInterface mismatch in num of variables: "
547 s << std::scientific <<
fVarn_1.xmin[ivar] <<
" " <<
fVarn_1.xmax[ivar] <<
" ";
553 n << std::scientific <<
fNeur_1.neuron[layer] <<
" ";
558 void* neuronnode=NULL;
561 stringstream weights;
562 weights.precision( 16 );
572 temp.precision( 16 );
574 temp << std::scientific <<
fDel_1.temp[layer] <<
" ";
586 stringstream content(minmaxcontent);
597 stringstream ncontent(neuronscontent);
601 ncontent >>
fNeur_1.neuron[layer];
606 void* neuronnode=NULL;
610 stringstream weights(neuronweights);
620 stringstream t(
temp);
633 o <<
"Number of vars " <<
fParam_1.nvar << std::endl;
634 o <<
"Output nodes " <<
fParam_1.lclass << std::endl;
638 o <<
"Var " << ivar <<
" [" <<
fVarn_1.xmin[ivar] <<
" - " <<
fVarn_1.xmax[ivar] <<
"]" << std::endl;
641 o <<
"Number of layers " <<
fParam_1.layerm << std::endl;
643 o <<
"Nodes per layer ";
659 for (
Int_t k=1; k<=kk; k++) {
660 Int_t jmin = 10*k - 9;
664 for (j=jmin; j<=jmax; j++) {
673 for (j=jmin; j<=jmax; j++) {
685 o <<
"Del.temp in layer " << layer <<
" : " <<
fDel_1.temp[layer] << std::endl;
694 fout <<
" // not implemented for class: \"" << className <<
"\"" << std::endl;
695 fout <<
"};" << std::endl;
#define REGISTER_METHOD(CLASS)
for example
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 nchar
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
TMatrixT< Float_t > TMatrix
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
Class that contains all the data information.
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
MethodBase(const TString &jobName, Types::EMVA methodType, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="")
standard constructor
TString GetMethodTypeName() const
Bool_t IgnoreEventsWithNegWeightsInTraining() const
const Event * GetEvent() const
DataSetInfo & DataInfo() const
void SetNormalised(Bool_t norm)
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
struct TMVA::MethodCFMlpANN_Utils::@367015201066363262016122100377006150256351063342 fVarn_1
Double_t temp[max_nLayers_]
struct TMVA::MethodCFMlpANN_Utils::@357056331205100014241125340265312042203142075057 fNeur_1
Double_t Ww_ref(const Double_t wwNN[], Int_t a_1, Int_t a_2) const
struct TMVA::MethodCFMlpANN_Utils::@255020153007270074077243245161143332317026253045 fParam_1
Int_t neuron[max_nLayers_]
struct TMVA::MethodCFMlpANN_Utils::@155012045125033222257014174357354245100233357312 fDel_1
Double_t W_ref(const Double_t wNN[], Int_t a_1, Int_t a_2, Int_t a_3) const
void Train_nn(Double_t *tin2, Double_t *tout2, Int_t *ntrain, Int_t *ntest, Int_t *nvar2, Int_t *nlayer, Int_t *nodes, Int_t *ncycle)
Double_t x[max_nLayers_ *max_nNodes_]
void SetLogger(MsgLogger *l)
Interface to Clermond-Ferrand artificial neural network.
Double_t GetMvaValue(Double_t *err=nullptr, Double_t *errUpper=nullptr)
returns CFMlpANN output (normalised within [0,1])
void PrintWeights(std::ostream &o) const
write the weights of the neural net
void MakeClassSpecific(std::ostream &, const TString &) const
Double_t GetData(Int_t isel, Int_t ivar) const
Int_t MethodCFMlpANN_nsel
Double_t EvalANN(std::vector< Double_t > &, Bool_t &isOK)
evaluates NN value as function of input variables
void DeclareOptions()
define the options (their key words) that can be set in the option string know options: NCycles=xx :t...
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t)
CFMlpANN can handle classification with 2 classes.
void NN_ava(Double_t *)
auxiliary functions
std::vector< Int_t > * fClass
void AddWeightsXMLTo(void *parent) const
write weights to xml file
void ProcessOptions()
decode the options in the option string
void Train(void)
training of the Clement-Ferrand NN classifier
Double_t NN_fonc(Int_t, Double_t) const
activation function
void ReadWeightsFromStream(std::istream &istr)
read back the weight from the training from file (stream)
void MakeClassSpecificHeader(std::ostream &, const TString &="") const
write specific classifier response for header
virtual ~MethodCFMlpANN(void)
destructor
MethodCFMlpANN(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="3000:N-1:N-2")
standard constructor
void Init(void)
default initialisation called by all constructors
Int_t GetClass(Int_t ivar) const
Int_t DataInterface(Double_t *, Double_t *, Int_t *, Int_t *, Int_t *, Int_t *, Double_t *, Int_t *, Int_t *)
data interface function
void ReadWeightsFromXML(void *wghtnode)
read weights from xml file
void GetHelpMessage() const
get help message text
Singleton class for Global types used by TMVA.
Ssiz_t First(char c) const
Find first occurrence of a character c.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Remove(Ssiz_t pos)
create variable transformations
MsgLogger & Endl(MsgLogger &ml)
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.