16#ifndef ROOT_INTERNAL_ML_RDATALOADERENGINE
17#define ROOT_INTERNAL_ML_RDATALOADERENGINE
20#include <condition_variable>
51template <
typename... Args>
79 std::vector<ROOT::RDF::RNode>
fRdfs;
117 std::vector<RColumnLayout>
layout;
118 layout.reserve(
sizeof...(Args));
287 throw std::runtime_error(
"RDataLoaderEngine::Save: this dataset is already being iterated elsewhere "
288 "(e.g. inside a training loop). Finish or stop that iteration before saving.");
295 if (
batch.GetSize() == 0)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
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 Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
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 ValidationRemainderRows()
RFlat2DMatrix fValidationDataset
bool fTrainingEpochActive
bool IsValidationActive()
std::vector< std::string > fCols
void ActivateTrainingEpoch()
Activate the training epoch by starting the batchloader.
std::size_t fValidationClusterIdx
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...
RFlat2DMatrix GetTrainBatch()
Loads a training batch from the queue.
RFlat2DMatrix fTrainingDataset
std::unique_ptr< RSampler > fValidationSampler
std::size_t fNumTrainingEntries
std::unique_ptr< RFlat2DMatrixOperators > fTensorOperators
RFlat2DMatrix fSampledValidationDataset
std::size_t fTrainingEpochCount
std::condition_variable fLoadingCondition
void CreateValidationBatches()
Creates validation batches by first loading a chunk (see RClusterLoader), and then split it into batc...
std::unique_ptr< RSampler > fTrainingSampler
std::size_t NumberOfValidationBatches()
std::vector< RFlat2DMatrix > fValidationDatasets
std::vector< std::size_t > fVecSizes
void LoadData()
Main loop for loading clusters and creating batches.
void CreateTrainBatches()
Create training batches by first loading a chunk (see RClusterLoader) and split it into batches (see ...
std::size_t fLowWatermark
RFlat2DMatrix GetValidationBatch()
Loads a validation batch from the queue.
RFlat2DMatrix fSampledTrainingDataset
std::unique_ptr< RBatchLoader > fTrainingBatchLoader
std::vector< ROOT::RDF::RNode > fRdfs
void DeActivateTrainingEpoch()
std::size_t fTrainingClusterIdx
std::size_t fHighWatermark
std::unique_ptr< RBatchLoader > fValidationBatchLoader
void Activate()
Activate the loading process by spawning the loading thread.
std::size_t fNumValidationEntries
std::size_t fValidationEpochCount
std::vector< RFlat2DMatrix > fTrainingDatasets
void ActivateValidationEpoch()
std::size_t fBatchesInMemory
std::unique_ptr< RDatasetLoader< Args... > > fDatasetLoader
std::size_t fBufferCapacity
std::size_t TrainRemainderRows()
std::size_t NumberOfTrainingBatches()
bool fValidationEpochActive
std::unique_ptr< std::thread > fLoadingThread
std::vector< RColumnLayout > MakeColumnLayout() const
Describe how the loader's columns map onto a batch-tensor row.
void DeActivateValidationEpoch()
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)
std::unique_ptr< RClusterLoader< Args... > > fClusterLoader
Load the whole dataset into memory.
void SplitDatasets()
Split the dataframes in a training and validation dataset.
const_iterator end() const
std::unique_ptr< RBatchSink > CreateBatchSink(std::string_view dataset_name, std::string_view filename, std::vector< RColumnLayout > layout, std::string_view format)
Create the sink matching format.
Opens a training or validation epoch and closes it again when done.
REpochGuard(RDataLoaderEngine &engine, bool isTraining)
RDataLoaderEngine & fEngine
Wrapper around ROOT::RVec<float> representing a 2D matrix.