17 std::vector<RColumnLayout> layout;
18 layout.reserve(
fCols.size());
20 std::size_t vecIdx = 0;
22 for (
const auto &col :
fCols) {
23 const bool isVector =
fRdfs[0].GetColumnType(col).find(
"RVec") != std::string::npos;
33 : fEngine(engine), fIsTraining(isTraining)
49 fEngine.DeActivateTrainingEpoch();
51 fEngine.DeActivateValidationEpoch();
55 const std::size_t batchesInMemory,
const std::vector<std::string> &cols,
56 const std::vector<std::size_t> &vecSizes,
const float vecPadding,
57 const float testSize,
bool shuffle,
bool dropRemainder,
const std::size_t setSeed,
58 bool loadEager, std::string sampleType,
float sampleRatio,
bool replacement)
182 std::string_view outputFormat)
186 throw std::runtime_error(
"RDataLoaderEngine::Save: this dataset is already being iterated elsewhere "
187 "(e.g. inside a training loop). Finish or stop that iteration before saving.");
196 sink->FillBatch(batch);
278 auto validationEmpty = [&] {
288 const std::size_t numTrainingClusters =
fClusterLoader->GetNumTrainingClusters();
304 if (validationEmpty()) {
319 std::vector<RClusterRange> trainClustersToLoad;
320 std::size_t accumulatedEntries = 0;
323 (!discovering || trainClustersToLoad.empty())) {
325 trainClustersToLoad.push_back(cluster);
326 accumulatedEntries += cluster.GetNumEntries();
338 std::size_t rowOffset = 0;
340 for (
auto &cluster : trainClustersToLoad) {
342 fClusterLoader->LoadTrainingClusterInto(stagingBuffer, cluster.rdfIdx, cluster.start, cluster.end);
346 cluster.SetNumEntries(loadedEntries);
348 rowOffset += cluster.GetNumEntries();
367 if (isLastBuffer && discovering) {
375 const std::size_t numValidationClusters =
fClusterLoader->GetNumValidationClusters();
398 std::vector<RClusterRange> valClustersToLoad;
399 std::size_t accumulatedEntries = 0;
402 valClustersToLoad.push_back(cluster);
403 accumulatedEntries += cluster.GetNumEntries();
412 std::size_t rowOffset = 0;
414 for (
const auto &cluster : valClustersToLoad) {
415 fClusterLoader->LoadValidationClusterInto(stagingBuffer, cluster.rdfIdx, cluster.start, cluster.end);
416 rowOffset += cluster.GetNumEntries();
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
void reserve(size_type N)
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
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.
RDataLoaderEngine & fEngine
REpochGuard(RDataLoaderEngine &engine, bool isTraining)
Wrapper around ROOT::RVec<float> representing a 2D matrix.
void Resize(std::size_t rows, std::size_t cols)
std::size_t GetSize() const