17from keras
import layers, models
21@contextlib.contextmanager
23 """Silence a known third-party warning and raise if it stops firing.
25 Notifies us to drop the workaround once the upstream library is fixed.
38 f
"Expected {category.__name__} containing {message!r} was not "
39 "emitted. This tutorial's workaround can probably be removed."
43def CreateModel(nlayers=4, nunits=64):
46 for i
in range(1, nlayers):
52 model.compile(loss=
"binary_crossentropy", optimizer=
"adam", weighted_metrics=[
"accuracy"])
62 sigData =
df1.AsNumpy(columns=[
"m_jj",
"m_jjj",
"m_lv",
"m_jlv",
"m_bb",
"m_wbb",
"m_wwbb"])
68 print(
"size of data", data_sig_size)
72 bkgData =
df2.AsNumpy(columns=[
"m_jj",
"m_jjj",
"m_lv",
"m_jlv",
"m_bb",
"m_wbb",
"m_wwbb"])
83 x_train, x_test, y_train, y_test =
train_test_split(inputs_data, inputs_targets, test_size=0.50, random_state=1234)
85 return x_train, y_train, x_test, y_test
90 modelFile = name +
".keras"
96 ctx =
expect_warning(DeprecationWarning,
"__array__ implementation doesn't accept a copy keyword")
103 return model, modelFile
109 if not exists(modelFile):
111 "INput model file not existing. You need to run TMVA_Higgs_Classification.C to generate the Keras trained model"
131model = CreateModel(3, 64)
132model, modelFile =
TrainModel(model, x_train, y_train,
"HiggsModel")
139modelHeaderFile = modelName +
".hxx"
152sofie =
getattr(ROOT,
"TMVA_SOFIE_" + modelName)
159print(
"input to model is ", x,
"\n\t -> output using SOFIE = ", y[0],
" using Keras = ", ykeras[0])
161if abs(y[0] - ykeras[0]) > 0.01:
162 raise RuntimeError(
"ERROR: Result is different between SOFIE and Keras")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...