// Class: ReadDL_CPU // Automatically generated by MethodBase::MakeClass // /* configuration options ===================================================== #GEN -*-*-*-*-*-*-*-*-*-*-*- general info -*-*-*-*-*-*-*-*-*-*-*- Method : DL::DL_CPU TMVA Release : 4.2.1 [262657] ROOT Release : 6.41/01 [403713] Creator : root Date : Tue May 19 20:08:55 2026 Host : Linux d4f37374721b 4.18.0-553.117.1.el8_10.x86_64 #1 SMP Sun Apr 5 23:14:32 EDT 2026 x86_64 GNU/Linux Dir : /github/home/master/notebooks Training events: 4000 Analysis type : [Classification] #OPT -*-*-*-*-*-*-*-*-*-*-*-*- options -*-*-*-*-*-*-*-*-*-*-*-*- # Set by User: V: "True" [Verbose output (short form of "VerbosityLevel" below - overrides the latter one)] VarTransform: "N" [List of variable transformations performed before training, e.g., "D_Background,P_Signal,G,N_AllClasses" for: "Decorrelation, PCA-transformation, Gaussianisation, Normalisation, each for the given class of events ('AllClasses' denotes all events of all classes, if no class indication is given, 'All' is assumed)"] H: "False" [Print method-specific help message] Layout: "TANH|100,TANH|50,TANH|10,LINEAR" [Layout of the network.] ErrorStrategy: "CROSSENTROPY" [Loss function: Mean squared error (regression) or cross entropy (binary classification).] WeightInitialization: "XAVIERUNIFORM" [Weight initialization strategy] Architecture: "CPU" [Which architecture to perform the training on.] TrainingStrategy: "Optimizer=ADAM,LearningRate=1e-3,TestRepetitions=1,ConvergenceSteps=10,BatchSize=100,MaxEpochs=20" [Defines the training strategies.] # Default: VerbosityLevel: "Verbose" [Verbosity level] CreateMVAPdfs: "False" [Create PDFs for classifier outputs (signal and background)] IgnoreNegWeightsInTraining: "False" [Events with negative weights are ignored in the training (but are included for testing and performance evaluation)] InputLayout: "0|0|0" [The Layout of the input] BatchLayout: "0|0|0" [The Layout of the batch] RandomSeed: "0" [Random seed used for weight initialization and batch shuffling] ValidationSize: "20%" [Part of the training data to use for validation. Specify as 0.2 or 20% to use a fifth of the data set as validation set. Specify as 100 to use exactly 100 events. (Default: 20%)] ## #VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*- NVar 4 var1 var1 var1 var1 'F' [-4.05916023254,3.26447582245] var2 var2 var2 Variable 2 'F' [-3.68905711174,3.78774046898] var3 var3 var3 Variable 3 units 'F' [-3.6296145916,3.91998791695] var4 var4 var4 Variable 4 units 'F' [-4.84856987,4.3625254631] NSpec 0 ============================================================================ */ #include #include #include #include #include #ifndef IClassifierReader__def #define IClassifierReader__def class IClassifierReader { public: // constructor IClassifierReader() : fStatusIsClean( true ) {} virtual ~IClassifierReader() {} // return classifier response virtual std::vector GetMulticlassValues( const std::vector& inputValues ) const = 0; // returns classifier status bool IsStatusClean() const { return fStatusIsClean; } protected: bool fStatusIsClean; }; #endif class ReadDL_CPU : public IClassifierReader { public: // constructor ReadDL_CPU( std::vector& theInputVars ) : IClassifierReader(), fClassName( "ReadDL_CPU" ), fNvars( 4 ) { // the training input variables const char* inputVars[] = { "var1", "var2", "var3", "var4" }; // sanity checks if (theInputVars.size() <= 0) { std::cout << "Problem in class \"" << fClassName << "\": empty input vector" << std::endl; fStatusIsClean = false; } if (theInputVars.size() != fNvars) { std::cout << "Problem in class \"" << fClassName << "\": mismatch in number of input values: " << theInputVars.size() << " != " << fNvars << std::endl; fStatusIsClean = false; } // validate input variables for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) { if (theInputVars[ivar] != inputVars[ivar]) { std::cout << "Problem in class \"" << fClassName << "\": mismatch in input variable names" << std::endl << " for variable [" << ivar << "]: " << theInputVars[ivar].c_str() << " != " << inputVars[ivar] << std::endl; fStatusIsClean = false; } } // initialize min and max vectors (for normalisation) fVmin[0] = -1; fVmax[0] = 1; fVmin[1] = -1; fVmax[1] = 1; fVmin[2] = -1; fVmax[2] = 1; fVmin[3] = -1; fVmax[3] = 1; // initialize input variable types fType[0] = 'F'; fType[1] = 'F'; fType[2] = 'F'; fType[3] = 'F'; // initialize constants Initialize(); // initialize transformation InitTransform(); } // destructor virtual ~ReadDL_CPU() { Clear(); // method-specific } // the classifier response // "inputValues" is a vector of input values in the same order as the // variables given to the constructor std::vector GetMulticlassValues( const std::vector& inputValues ) const override; private: // method-specific destructor void Clear(); // input variable transformation double fOff_1[5][4]; double fScal_1[5][4]; void InitTransform_1(); void Transform_1( std::vector & iv, int sigOrBgd ) const; void InitTransform(); void Transform( std::vector & iv, int sigOrBgd ) const; // common member variables const char* fClassName; const size_t fNvars; size_t GetNvar() const { return fNvars; } char GetType( int ivar ) const { return fType[ivar]; } // normalisation of input variables double fVmin[4]; double fVmax[4]; double NormVariable( double x, double xmin, double xmax ) const { // normalise to output range: [-1, 1] return 2*(x - xmin)/(xmax - xmin) - 1.0; } // type of input variable: 'F' or 'I' char fType[4]; // initialize internal variables void Initialize(); std::vector GetMulticlassValues__( const std::vector& inputValues ) const; // private members (method specific) inline std::vector ReadDL_CPU::GetMulticlassValues( const std::vector& inputValues ) const { // classifier response value std::vector retval; // classifier response, sanity check first if (!IsStatusClean()) { std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response" << " because status is dirty" << std::endl; } else { std::vector iV(inputValues); Transform( iV, -1 ); retval = GetMulticlassValues__( iV ); } return retval; } //_______________________________________________________________________ inline void ReadDL_CPU::InitTransform_1() { double fMin_1[5][4]; double fMax_1[5][4]; // Normalization transformation, initialisation fMin_1[0][0] = -3.12874746323; fMax_1[0][0] = 3.26447582245; fScal_1[0][0] = 2.0/(fMax_1[0][0]-fMin_1[0][0]); fOff_1[0][0] = fMin_1[0][0]*fScal_1[0][0]+1.; fMin_1[1][0] = -4.05916023254; fMax_1[1][0] = 2.87491154671; fScal_1[1][0] = 2.0/(fMax_1[1][0]-fMin_1[1][0]); fOff_1[1][0] = fMin_1[1][0]*fScal_1[1][0]+1.; fMin_1[2][0] = -3.18505716324; fMax_1[2][0] = 2.87491154671; fScal_1[2][0] = 2.0/(fMax_1[2][0]-fMin_1[2][0]); fOff_1[2][0] = fMin_1[2][0]*fScal_1[2][0]+1.; fMin_1[3][0] = -1.16817617416; fMax_1[3][0] = 1.72694301605; fScal_1[3][0] = 2.0/(fMax_1[3][0]-fMin_1[3][0]); fOff_1[3][0] = fMin_1[3][0]*fScal_1[3][0]+1.; fMin_1[4][0] = -4.05916023254; fMax_1[4][0] = 3.26447582245; fScal_1[4][0] = 2.0/(fMax_1[4][0]-fMin_1[4][0]); fOff_1[4][0] = fMin_1[4][0]*fScal_1[4][0]+1.; fMin_1[0][1] = -3.08905720711; fMax_1[0][1] = 3.1251244545; fScal_1[0][1] = 2.0/(fMax_1[0][1]-fMin_1[0][1]); fOff_1[0][1] = fMin_1[0][1]*fScal_1[0][1]+1.; fMin_1[1][1] = -3.68905711174; fMax_1[1][1] = 3.18774032593; fScal_1[1][1] = 2.0/(fMax_1[1][1]-fMin_1[1][1]); fOff_1[1][1] = fMin_1[1][1]*fScal_1[1][1]+1.; fMin_1[2][1] = -2.65968227386; fMax_1[2][1] = 3.78774046898; fScal_1[2][1] = 2.0/(fMax_1[2][1]-fMin_1[2][1]); fOff_1[2][1] = fMin_1[2][1]*fScal_1[2][1]+1.; fMin_1[3][1] = -1.5123976469; fMax_1[3][1] = 1.68332743645; fScal_1[3][1] = 2.0/(fMax_1[3][1]-fMin_1[3][1]); fOff_1[3][1] = fMin_1[3][1]*fScal_1[3][1]+1.; fMin_1[4][1] = -3.68905711174; fMax_1[4][1] = 3.78774046898; fScal_1[4][1] = 2.0/(fMax_1[4][1]-fMin_1[4][1]); fOff_1[4][1] = fMin_1[4][1]*fScal_1[4][1]+1.; fMin_1[0][2] = -3.57268309593; fMax_1[0][2] = 3.91515159607; fScal_1[0][2] = 2.0/(fMax_1[0][2]-fMin_1[0][2]); fOff_1[0][2] = fMin_1[0][2]*fScal_1[0][2]+1.; fMin_1[1][2] = -3.6296145916; fMax_1[1][2] = 3.56402516365; fScal_1[1][2] = 2.0/(fMax_1[1][2]-fMin_1[1][2]); fOff_1[1][2] = fMin_1[1][2]*fScal_1[1][2]+1.; fMin_1[2][2] = -3.57268309593; fMax_1[2][2] = 3.91998791695; fScal_1[2][2] = 2.0/(fMax_1[2][2]-fMin_1[2][2]); fOff_1[2][2] = fMin_1[2][2]*fScal_1[2][2]+1.; fMin_1[3][2] = -1.88815784454; fMax_1[3][2] = 1.89106762409; fScal_1[3][2] = 2.0/(fMax_1[3][2]-fMin_1[3][2]); fOff_1[3][2] = fMin_1[3][2]*fScal_1[3][2]+1.; fMin_1[4][2] = -3.6296145916; fMax_1[4][2] = 3.91998791695; fScal_1[4][2] = 2.0/(fMax_1[4][2]-fMin_1[4][2]); fOff_1[4][2] = fMin_1[4][2]*fScal_1[4][2]+1.; fMin_1[0][3] = -3.29704141617; fMax_1[0][3] = 4.3625254631; fScal_1[0][3] = 2.0/(fMax_1[0][3]-fMin_1[0][3]); fOff_1[0][3] = fMin_1[0][3]*fScal_1[0][3]+1.; fMin_1[1][3] = -4.84856987; fMax_1[1][3] = 3.54116511345; fScal_1[1][3] = 2.0/(fMax_1[1][3]-fMin_1[1][3]); fOff_1[1][3] = fMin_1[1][3]*fScal_1[1][3]+1.; fMin_1[2][3] = -4.79704141617; fMax_1[2][3] = 2.8625254631; fScal_1[2][3] = 2.0/(fMax_1[2][3]-fMin_1[2][3]); fOff_1[2][3] = fMin_1[2][3]*fScal_1[2][3]+1.; fMin_1[3][3] = -1.89776241779; fMax_1[3][3] = 1.89909875393; fScal_1[3][3] = 2.0/(fMax_1[3][3]-fMin_1[3][3]); fOff_1[3][3] = fMin_1[3][3]*fScal_1[3][3]+1.; fMin_1[4][3] = -4.84856987; fMax_1[4][3] = 4.3625254631; fScal_1[4][3] = 2.0/(fMax_1[4][3]-fMin_1[4][3]); fOff_1[4][3] = fMin_1[4][3]*fScal_1[4][3]+1.; } //_______________________________________________________________________ inline void ReadDL_CPU::Transform_1( std::vector& iv, int cls) const { // Normalization transformation if (cls < 0 || cls > 4) { if (4 > 1 ) cls = 4; else cls = 2; } const int nVar = 4; // get indices of used variables // define the indices of the variables which are transformed by this transformation static std::vector indicesGet; static std::vector indicesPut; if ( indicesGet.empty() ) { indicesGet.reserve(fNvars); indicesGet.push_back( 0); indicesGet.push_back( 1); indicesGet.push_back( 2); indicesGet.push_back( 3); } if ( indicesPut.empty() ) { indicesPut.reserve(fNvars); indicesPut.push_back( 0); indicesPut.push_back( 1); indicesPut.push_back( 2); indicesPut.push_back( 3); } static std::vector dv; dv.resize(nVar); for (int ivar=0; ivar& iv, int sigOrBgd ) const { Transform_1( iv, sigOrBgd ); }