16#ifndef ROOT_INTERNAL_ML_RDATALOADERENGINE
17#define ROOT_INTERNAL_ML_RDATALOADERENGINE
19#include <condition_variable>
36template <
typename Proxied>
38using RNode = RInterface<::ROOT::Detail::RDF::RNodeBase>;
90 std::vector<ROOT::RDF::RNode>
fRdfs;
137 RDataLoaderEngine(
const std::vector<ROOT::RDF::RNode> &rdfs,
const std::size_t batchSize,
138 const std::size_t batchesInMemory,
const std::vector<std::string> &cols,
139 const std::vector<std::size_t> &vecSizes = {},
const float vecPadding = 0.0,
140 const float testSize = 0.0,
bool shuffle =
true,
bool dropRemainder =
true,
141 const std::size_t setSeed = 0,
bool loadEager =
false, std::string sampleType =
"",
142 float sampleRatio = 1.0,
bool replacement =
false);
150 void Save(std::string_view dataset_name, std::string_view
filename,
bool isTraining, std::string_view outputFormat);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Building and loading the batches from loaded chunks in RChunkLoader.
Loads TTree/RNTuple clusters from one or more RDataFrames into RFlat2DMatrix buffers for ML training ...
In this class, the processes of loading clusters (see RClusterLoader) and creating batches from those...
std::size_t TrainRemainderRows()
std::vector< ROOT::RDF::RNode > fRdfs
std::unique_ptr< RFlat2DMatrixOperators > fTensorOperators
RFlat2DMatrix GetValidationBatch()
Loads a validation batch from the queue.
std::vector< RFlat2DMatrix > fTrainingDatasets
std::unique_ptr< RDatasetLoader > fDatasetLoader
std::unique_ptr< std::thread > fLoadingThread
void Activate()
Activate the loading process by spawning the loading thread.
void Save(std::string_view dataset_name, std::string_view filename, bool isTraining, std::string_view outputFormat)
Materialize one train/test split to disk by draining a full epoch through the normal batch pipeline a...
std::unique_ptr< RClusterLoader > fClusterLoader
std::size_t fLowWatermark
void ActivateValidationEpoch()
bool IsValidationActive()
bool fValidationEpochActive
std::size_t fNumTrainingEntries
RFlat2DMatrix fSampledTrainingDataset
std::size_t fValidationEpochCount
std::vector< RColumnLayout > MakeColumnLayout()
Describe how the loader's columns map onto a batch-tensor row.
std::vector< std::size_t > fVecSizes
std::size_t fTrainingEpochCount
std::size_t fTrainingClusterIdx
std::unique_ptr< RSampler > fValidationSampler
void LoadData()
Main loop for loading clusters and creating batches.
std::unique_ptr< RSampler > fTrainingSampler
std::size_t fNumValidationEntries
std::size_t fBufferCapacity
RFlat2DMatrix fSampledValidationDataset
std::size_t fValidationClusterIdx
std::size_t NumberOfTrainingBatches()
std::vector< RColumnLayout > fColumnLayout
std::vector< RFlat2DMatrix > fValidationDatasets
void ActivateTrainingEpoch()
Activate the training epoch by starting the batchloader.
std::size_t ValidationRemainderRows()
void CreateValidationBatches()
Creates validation batches by first loading a chunk (see RClusterLoader), and then split it into batc...
std::vector< std::string > fCols
RDataLoaderEngine(const std::vector< ROOT::RDF::RNode > &rdfs, const std::size_t batchSize, const std::size_t batchesInMemory, const std::vector< std::string > &cols, const std::vector< std::size_t > &vecSizes={}, const float vecPadding=0.0, const float testSize=0.0, bool shuffle=true, bool dropRemainder=true, const std::size_t setSeed=0, bool loadEager=false, std::string sampleType="", float sampleRatio=1.0, bool replacement=false)
void DeActivateValidationEpoch()
RFlat2DMatrix fTrainingDataset
RFlat2DMatrix GetTrainBatch()
Loads a training batch from the queue.
void DeActivateTrainingEpoch()
bool fTrainingEpochActive
RFlat2DMatrix fValidationDataset
std::size_t NumberOfValidationBatches()
std::condition_variable fLoadingCondition
void CreateTrainBatches()
Create training batches by first loading a chunk (see RClusterLoader) and split it into batches (see ...
std::unique_ptr< RBatchLoader > fTrainingBatchLoader
std::unique_ptr< RBatchLoader > fValidationBatchLoader
Load the whole dataset into memory.
Collection of operations applied to one or multiple flat 2D matrices.
Implementation of different sampling strategies.
RInterface<::ROOT::Detail::RDF::RNodeBase > RNode
Where one of the loader's columns lives inside a batch-tensor row and how it's shaped.
Opens a training or validation epoch and closes it again when done.
RDataLoaderEngine & fEngine
REpochGuard(RDataLoaderEngine &engine, bool isTraining)
Wrapper around ROOT::RVec<float> representing a 2D matrix.