92 using std::stringstream;
140 MethodCFMlpANN_nsel(0)
142 MethodCFMlpANN_Utils::SetLogger(&
Log());
157 MethodCFMlpANN_nsel(0)
188 Int_t currentHiddenLayer = 1;
190 while(layerSpec.
Length()>0) {
192 if (layerSpec.
First(
',')<0) {
197 sToAdd = layerSpec(0,layerSpec.
First(
','));
198 layerSpec = layerSpec(layerSpec.First(
',')+1,layerSpec.Length());
202 nNodes += atoi(sToAdd);
203 fNodes[currentHiddenLayer++] = nNodes;
210 Log() <<
kFATAL <<
"Mechanism to ignore events with negative weights in training not yet available for method: " 212 <<
" --> please remove \"IgnoreNegWeightsInTraining\" option from booking string." 216 Log() <<
kINFO <<
"Use configuration (nodes per layer): in=";
230 fClass =
new std::vector<Int_t>( nEvtTrain );
235 for (
Int_t ievt=0; ievt<nEvtTrain; ievt++) {
242 for (ivar=0; ivar<
GetNvar(); ivar++) {
243 (*fData)( ievt, ivar ) = ev->
GetValue(ivar);
287 Int_t ntrain(
Data()->GetNTrainingEvents());
294 for (
Int_t i=0; i<nlayers; i++) nodes[i] =
fNodes[i];
302 for (
Int_t layer=0; layer<nlayers; layer++)
307 Train_nn( &dumDat, &dumDat, &ntrain, &ntest, &nvar, &nlayers, nodes, &ncycles );
309 Log() <<
kWARNING <<
"<Train> sorry CFMlpANN does not run on Windows" <<
Endl;
327 std::vector<Double_t> inputVec(
GetNvar() );
331 if (!isOK)
Log() <<
kFATAL <<
"EvalANN returns (!isOK) for event " <<
Endl;
346 for (
UInt_t ivar=0; ivar<
GetNvar(); ivar++) xeev[ivar] = inVar[ivar];
352 if (
fVarn_1.xmax[jvar] < xeev[jvar]) xeev[jvar] =
fVarn_1.xmax[jvar];
353 if (
fVarn_1.xmin[jvar] > xeev[jvar]) xeev[jvar] =
fVarn_1.xmin[jvar];
359 xeev[jvar] = xeev[jvar] - ((
fVarn_1.xmax[jvar] +
fVarn_1.xmin[jvar])/2);
360 xeev[jvar] = xeev[jvar] / ((
fVarn_1.xmax[jvar] -
fVarn_1.xmin[jvar])/2);
378 for (
Int_t ivar=0; ivar<
fNeur_1.neuron[0]; ivar++)
fYNN[0][ivar] = xeev[ivar];
400 if (u/
fDel_1.temp[i] > 170) f = +1;
401 else if (u/
fDel_1.temp[i] < -170) f = -1;
404 f = (1 - yy)/(1 + yy);
422 Log() <<
kFATAL <<
"<ReadWeightsFromFile> mismatch in number of variables" <<
Endl;
426 Log() <<
kFATAL <<
"<ReadWeightsFromFile> mismatch in number of classes" <<
Endl;
430 Log() <<
kFATAL <<
"<ReadWeightsFromStream> reached EOF prematurely " <<
Endl;
453 const Int_t nchar( 100 );
454 char* dumchar =
new char[nchar];
466 for (
Int_t k=1; k<=kk; k++) {
467 Int_t jmin = 10*k - 9;
470 for (
Int_t j=jmin; j<=jmax; j++) {
474 for (
Int_t j=jmin; j<=jmax; j++) {
479 istr.getline( dumchar, nchar );
486 istr.getline( dumchar, nchar );
487 istr.getline( dumchar, nchar );
489 istr >>
fDel_1.temp[layer];
494 Log() <<
kFATAL <<
"<ReadWeightsFromFile> mismatch in zeroth layer:" 516 Log() <<
kFATAL <<
"ERROR in MethodCFMlpANN_DataInterface zero pointer xpg" <<
Endl;
519 Log() <<
kFATAL <<
"ERROR in MethodCFMlpANN_DataInterface mismatch in num of variables: " 546 s << std::scientific <<
fVarn_1.xmin[ivar] <<
" " <<
fVarn_1.xmax[ivar] <<
" ";
552 n << std::scientific <<
fNeur_1.neuron[layer] <<
" ";
557 void* neuronnode=
NULL;
560 stringstream weights;
561 weights.precision( 16 );
571 temp.precision( 16 );
573 temp << std::scientific <<
fDel_1.temp[layer] <<
" ";
585 stringstream content(minmaxcontent);
596 stringstream ncontent(neuronscontent);
600 ncontent >>
fNeur_1.neuron[layer];
605 void* neuronnode=
NULL;
609 stringstream weights(neuronweights);
619 stringstream t(temp);
632 o <<
"Number of vars " <<
fParam_1.nvar << std::endl;
633 o <<
"Output nodes " <<
fParam_1.lclass << std::endl;
637 o <<
"Var " << ivar <<
" [" <<
fVarn_1.xmin[ivar] <<
" - " <<
fVarn_1.xmax[ivar] <<
"]" << std::endl;
640 o <<
"Number of layers " <<
fParam_1.layerm << std::endl;
642 o <<
"Nodes per layer ";
645 o <<
fNeur_1.neuron[layer] <<
" ";
658 for (
Int_t k=1; k<=kk; k++) {
659 Int_t jmin = 10*k - 9;
663 for (j=jmin; j<=jmax; j++) {
671 for (i=1; i<=
fNeur_1.neuron[layer-1]; i++) {
672 for (j=jmin; j<=jmax; j++) {
684 o <<
"Del.temp in layer " << layer <<
" : " <<
fDel_1.temp[layer] << std::endl;
691 fout <<
" // not implemented for class: \"" << className <<
"\"" << std::endl;
692 fout <<
"};" << std::endl;
struct TMVA::MethodCFMlpANN_Utils::@183 fDel_1
Double_t GetData(Int_t isel, Int_t ivar) const
void Train(void)
training of the Clement-Ferrand NN classifier
void DeclareOptions()
define the options (their key words) that can be set in the option string know options: NCycles=xx :t...
MsgLogger & Endl(MsgLogger &ml)
Double_t temp[max_nLayers_]
void NN_ava(Double_t *)
auxiliary functions
void MakeClassSpecificHeader(std::ostream &, const TString &="") const
write specific classifier response for header
Int_t GetClass(Int_t ivar) const
void ReadWeightsFromXML(void *wghtnode)
read weights from xml file
void MakeClassSpecific(std::ostream &, const TString &) const
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
Double_t W_ref(const Double_t wNN[], Int_t a_1, Int_t a_2, Int_t a_3) 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
virtual ~MethodCFMlpANN(void)
destructor
Int_t MethodCFMlpANN_nsel
const Event * GetEvent() const
std::vector< Int_t > * fClass
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t)
CFMlpANN can handle classification with 2 classes.
DataSetInfo & DataInfo() const
Ssiz_t First(char c) const
Find first occurrence of a character c.
void PrintWeights(std::ostream &o) const
write the weights of the neural net
Long64_t GetNTrainingEvents() const
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
returns CFMlpANN output (normalised within [0,1])
Double_t NN_fonc(Int_t, Double_t) const
activation function
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 Ww_ref(const Double_t wwNN[], Int_t a_1, Int_t a_2) const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Double_t x[max_nLayers_ *max_nNodes_]
void GetHelpMessage() const
get help message text
struct TMVA::MethodCFMlpANN_Utils::@182 fNeur_1
Double_t EvalANN(std::vector< Double_t > &, Bool_t &isOK)
evaluates NN value as function of input variables
void ReadWeightsFromStream(std::istream &istr)
read back the weight from the training from file (stream)
void SetNormalised(Bool_t norm)
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
TString & Remove(Ssiz_t pos)
Bool_t IgnoreEventsWithNegWeightsInTraining() const
Int_t neuron[max_nLayers_]
void AddWeightsXMLTo(void *parent) const
write weights to xml file
TMatrixT< Float_t > TMatrix
void Init(void)
default initialisation called by all constructors
void ProcessOptions()
decode the options in the option string
#define REGISTER_METHOD(CLASS)
for example
Abstract ClassifierFactory template that handles arbitrary types.
TString GetMethodTypeName() const
struct TMVA::MethodCFMlpANN_Utils::@181 fVarn_1
Bool_t IsSignal(const Event *ev) const
MethodCFMlpANN(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="3000:N-1:N-2")
standard constructor option string: "n_training_cycles:n_hidden_layers" default is: n_training_cycles...
struct TMVA::MethodCFMlpANN_Utils::@180 fParam_1
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
if(line.BeginsWith("/*"))