ROOT
v6-30
Reference Guide
Loading...
Searching...
No Matches
RBatchGenerator_NumPy.py
Go to the documentation of this file.
1
### \file
2
### \ingroup tutorial_tmva
3
### \notebook -nodraw
4
###
5
### Example of getting batches of events from a ROOT dataset as Python
6
### generators of numpy arrays.
7
###
8
### \macro_code
9
### \macro_output
10
### \author Dante Niewenhuis
11
12
import
ROOT
13
14
tree_name =
"sig_tree"
15
file_name =
"http://root.cern/files/Higgs_data.root"
16
17
batch_size = 128
18
chunk_size = 5_000
19
20
ds_train, ds_validation = ROOT.TMVA.Experimental.CreateNumPyGenerators(
21
tree_name,
22
file_name,
23
batch_size,
24
chunk_size,
25
validation_split=0.3,
26
shuffle=
True
,
27
)
28
29
# Loop through training set
30
for
i, b
in
enumerate(ds_train):
31
print(f
"Training batch {i} => {b.shape}"
)
32
33
34
# Loop through Validation set
35
for
i, b
in
enumerate(ds_validation):
36
print(f
"Validation batch {i} => {b.shape}"
)
tutorials
tmva
RBatchGenerator_NumPy.py
ROOT v6-30 - Reference Guide Generated on Thu Dec 12 2024 06:12:41 (GVA Time) using Doxygen 1.9.8