ROOT
Version v6.32
master
v6.34
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
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 = str(
ROOT.gROOT.GetTutorialDir
()) +
"/tmva/data/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}"
)
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
tutorials
tmva
RBatchGenerator_NumPy.py
ROOT v6-32 - Reference Guide Generated on Mon Mar 31 2025 15:38:52 (GVA Time) using Doxygen 1.10.0