From 34213891ea3f2dab8b7c2b88332e0fa4eb4e7111 Mon Sep 17 00:00:00 2001 From: moneta Date: Wed, 3 Apr 2024 19:36:36 +0200 Subject: [PATCH] [tutorials][tmva] Use different name for header and weights in some SOFIE tutorials --- tutorials/tmva/TMVA_SOFIE_Inference.py | 5 ++--- tutorials/tmva/TMVA_SOFIE_RDataFrame.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tutorials/tmva/TMVA_SOFIE_Inference.py b/tutorials/tmva/TMVA_SOFIE_Inference.py index e658c78939ba3c..5406c0ce0b5ca9 100644 --- a/tutorials/tmva/TMVA_SOFIE_Inference.py +++ b/tutorials/tmva/TMVA_SOFIE_Inference.py @@ -31,7 +31,7 @@ # parse the input Keras model into RModel object model = ROOT.TMVA.Experimental.SOFIE.PyKeras.Parse(modelFile) -generatedHeaderFile = modelFile.replace(".h5",".hxx") +generatedHeaderFile = "generatedSofieHiggsModel.hxx" #modelFile.replace(".h5",".hxx") print("Generating inference code for the Keras model from ",modelFile,"in the header ", generatedHeaderFile) #Generating inference code model.Generate() @@ -44,7 +44,6 @@ ROOT.gInterpreter.Declare('#include "' + generatedHeaderFile + '"') -generatedHeaderFile = modelFile.replace(".h5",".hxx") print("Generating inference code for the Keras model from ",modelFile,"in the header ", generatedHeaderFile) #Generating inference @@ -67,7 +66,7 @@ print("size of data", dataset_size) #instantiate SOFIE session class -session = ROOT.TMVA_SOFIE_Higgs_trained_model.Session() +session = ROOT.TMVA_SOFIE_Higgs_trained_model.Session("generatedSofieHiggsModel.dat") hs = ROOT.TH1D("hs","Signal result",100,0,1) for i in range(0,dataset_size): diff --git a/tutorials/tmva/TMVA_SOFIE_RDataFrame.py b/tutorials/tmva/TMVA_SOFIE_RDataFrame.py index 67683c88f4b6a8..dab9309a48912c 100644 --- a/tutorials/tmva/TMVA_SOFIE_RDataFrame.py +++ b/tutorials/tmva/TMVA_SOFIE_RDataFrame.py @@ -27,14 +27,14 @@ # generating inference code model.Generate() -model.OutputGenerated("Higgs_trained_model.hxx") +model.OutputGenerated("Higgs_generated_Sofie_model.hxx") model.PrintGenerated() # compile using ROOT JIT trained model print("compiling SOFIE model and functor....") -ROOT.gInterpreter.Declare('#include "Higgs_trained_model.hxx"') +ROOT.gInterpreter.Declare('#include "Higgs_generated_Sofie_model.hxx"') modelName = "Higgs_trained_model" -ROOT.gInterpreter.Declare('auto sofie_functor = TMVA::Experimental::SofieFunctor<7,TMVA_SOFIE_'+modelName+'::Session>(0);') +ROOT.gInterpreter.Declare('auto sofie_functor = TMVA::Experimental::SofieFunctor<7,TMVA_SOFIE_'+modelName+'::Session>(0,"Higgs_generated_Sofie_model.dat");') # run inference over input data inputFile = "http://root.cern/files/Higgs_data.root"