28 sigData =
df1.AsNumpy(columns=[
"m_jj",
"m_jjj",
"m_lv",
"m_jlv",
"m_bb",
"m_wbb",
"m_wwbb"])
34 print(
"size of data", data_sig_size)
38 bkgData =
df2.AsNumpy(columns=[
"m_jj",
"m_jjj",
"m_lv",
"m_jlv",
"m_bb",
"m_wbb",
"m_wwbb"])
52 x_train = inputs_data[idx[:ntrain]]
53 y_train = inputs_targets[idx[:ntrain]].
reshape(-1, 1)
54 x_test = inputs_data[idx[ntrain:]]
55 y_test = inputs_targets[idx[ntrain:]].
reshape(-1, 1)
57 return x_train, y_train, x_test, y_test
63 for i
in range(1, nlayers):
77 nbatches =
x.shape[0] // batch_size
78 for epoch
in range(epochs):
81 for i
in range(nbatches):
82 idx = perm[i * batch_size : (i + 1) * batch_size]
88 print(f
"Epoch {epoch + 1}/{epochs} - average loss: {running_loss / nbatches:.4f}")
97 modelFile = modelName +
".onnx"
108 input_names=[
"input"],
109 output_names=[
"output"],
113 print(
"calling torch.onnx.export with parameters", kwargs)
117 print(
"model exported to ONNX as", modelFile)
145TrainModel(model, x_train, y_train)
157modelHeaderFile = modelName +
".hxx"
175 print(
"input to model is ", x_check[i],
"\n\t -> output using SOFIE = ", y[0],
" using PyTorch = ", ytorch[i, 0])
176 if abs(y[0] - ytorch[i, 0]) > 0.01:
177 raise RuntimeError(
"ERROR: Result is different between SOFIE and PyTorch")
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 ,...
CreateModel(nlayers=4, nunits=64)
GenerateCode(modelFile="model.onnx")
ExportModel(model, modelName)
TrainModel(model, x, y, epochs=5, batch_size=50)