Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::Internal::ML::RBatchGenerator< Args > Class Template Reference

template<typename... Args>
class ROOT::Experimental::Internal::ML::RBatchGenerator< Args >

In this class, the processes of loading chunks (see RChunkLoader) and creating batches from those chunks (see RBatchLoader) are combined, allowing batches from the training and validation sets to be loaded directly from a dataset in an RDataFrame.

Definition at line 52 of file RBatchGenerator.hxx.

Public Member Functions

 RBatchGenerator (const std::vector< ROOT::RDF::RNode > &rdfs, const std::size_t chunkSize, const std::size_t blockSize, const std::size_t batchSize, const std::vector< std::string > &cols, const std::vector< std::size_t > &vecSizes={}, const float vecPadding=0.0, const float validationSplit=0.0, const std::size_t maxChunks=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)
 
 ~RBatchGenerator ()
 
void Activate ()
 Activate the loading process by spawning the loading thread.
 
void ActivateTrainingEpoch ()
 Activate the training epoch by starting the batchloader.
 
void ActivateValidationEpoch ()
 
void CreateTrainBatches ()
 Create training batches by first loading a chunk (see RChunkLoader) and split it into batches (see RBatchLoader)
 
void CreateValidationBatches ()
 Creates validation batches by first loading a chunk (see RChunkLoader), and then split it into batches (see RBatchLoader)
 
void DeActivate ()
 
void DeActivateTrainingEpoch ()
 
void DeActivateValidationEpoch ()
 
RFlat2DMatrix GetTrainBatch ()
 Loads a training batch from the queue.
 
RFlat2DMatrix GetValidationBatch ()
 Loads a validation batch from the queue.
 
bool IsActive ()
 
bool IsTrainingActive ()
 
bool IsValidationActive ()
 
void LoadChunks ()
 Main loop for loading chunks and creating batches.
 
std::size_t NumberOfTrainingBatches ()
 
std::size_t NumberOfValidationBatches ()
 
std::size_t TrainRemainderRows ()
 
std::size_t ValidationRemainderRows ()
 

Private Attributes

std::size_t fBatchSize
 
std::size_t fBlockSize
 
std::unique_ptr< RChunkLoader< Args... > > fChunkLoader
 
std::size_t fChunkSize
 
std::vector< std::string > fCols
 
std::unique_ptr< RDatasetLoader< Args... > > fDatasetLoader
 
bool fDropRemainder
 
bool fEpochActive {false}
 
bool fIsActive {false}
 
bool fLoadEager
 
std::condition_variable fLoadingCondition
 
std::mutex fLoadingMutex
 
std::unique_ptr< std::thread > fLoadingThread
 
std::size_t fMaxChunks
 
std::size_t fNumTrainingChunks
 
std::size_t fNumTrainingEntries
 
std::size_t fNumValidationChunks
 
std::size_t fNumValidationEntries
 
std::vector< ROOT::RDF::RNodefRdfs
 
bool fReplacement
 
RFlat2DMatrix fSampledTrainingDataset
 
RFlat2DMatrix fSampledValidationDataset
 
float fSampleRatio
 
std::string fSampleType
 
std::size_t fSetSeed
 
bool fShuffle
 
std::unique_ptr< RFlat2DMatrixOperatorsfTensorOperators
 
RFlat2DMatrix fTrainChunkTensor
 
std::unique_ptr< RBatchLoaderfTrainingBatchLoader
 
std::size_t fTrainingChunkNum {0}
 
RFlat2DMatrix fTrainingDataset
 
std::vector< RFlat2DMatrixfTrainingDatasets
 
bool fTrainingEpochActive {false}
 
std::unique_ptr< RSamplerfTrainingSampler
 
bool fUseWholeFile
 
std::unique_ptr< RBatchLoaderfValidationBatchLoader
 
std::size_t fValidationChunkNum {0}
 
RFlat2DMatrix fValidationChunkTensor
 
RFlat2DMatrix fValidationDataset
 
std::vector< RFlat2DMatrixfValidationDatasets
 
bool fValidationEpochActive {false}
 
std::unique_ptr< RSamplerfValidationSampler
 
float fValidationSplit
 
std::vector< std::size_t > fVecSizes
 

#include <ROOT/ML/RBatchGenerator.hxx>

Constructor & Destructor Documentation

◆ RBatchGenerator()

template<typename... Args>
ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::RBatchGenerator ( const std::vector< ROOT::RDF::RNode > & rdfs,
const std::size_t chunkSize,
const std::size_t blockSize,
const std::size_t batchSize,
const std::vector< std::string > & cols,
const std::vector< std::size_t > & vecSizes = {},
const float vecPadding = 0.0,
const float validationSplit = 0.0,
const std::size_t maxChunks = 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 )
inline

Definition at line 117 of file RBatchGenerator.hxx.

◆ ~RBatchGenerator()

template<typename... Args>
ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::~RBatchGenerator ( )
inline

Definition at line 194 of file RBatchGenerator.hxx.

Member Function Documentation

◆ Activate()

template<typename... Args>
void ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::Activate ( )
inline

Activate the loading process by spawning the loading thread.

Definition at line 217 of file RBatchGenerator.hxx.

◆ ActivateTrainingEpoch()

template<typename... Args>
void ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::ActivateTrainingEpoch ( )
inline

Activate the training epoch by starting the batchloader.

Definition at line 235 of file RBatchGenerator.hxx.

◆ ActivateValidationEpoch()

template<typename... Args>
void ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::ActivateValidationEpoch ( )
inline

Definition at line 259 of file RBatchGenerator.hxx.

◆ CreateTrainBatches()

template<typename... Args>
void ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::CreateTrainBatches ( )
inline

Create training batches by first loading a chunk (see RChunkLoader) and split it into batches (see RBatchLoader)

Definition at line 398 of file RBatchGenerator.hxx.

◆ CreateValidationBatches()

template<typename... Args>
void ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::CreateValidationBatches ( )
inline

Creates validation batches by first loading a chunk (see RChunkLoader), and then split it into batches (see RBatchLoader)

Definition at line 420 of file RBatchGenerator.hxx.

◆ DeActivate()

template<typename... Args>
void ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::DeActivate ( )
inline

Definition at line 196 of file RBatchGenerator.hxx.

◆ DeActivateTrainingEpoch()

template<typename... Args>
void ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::DeActivateTrainingEpoch ( )
inline

Definition at line 247 of file RBatchGenerator.hxx.

◆ DeActivateValidationEpoch()

template<typename... Args>
void ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::DeActivateValidationEpoch ( )
inline

Definition at line 271 of file RBatchGenerator.hxx.

◆ GetTrainBatch()

template<typename... Args>
RFlat2DMatrix ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::GetTrainBatch ( )
inline

Loads a training batch from the queue.

Definition at line 443 of file RBatchGenerator.hxx.

◆ GetValidationBatch()

template<typename... Args>
RFlat2DMatrix ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::GetValidationBatch ( )
inline

Loads a validation batch from the queue.

Definition at line 450 of file RBatchGenerator.hxx.

◆ IsActive()

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::IsActive ( )
inline

Definition at line 462 of file RBatchGenerator.hxx.

◆ IsTrainingActive()

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::IsTrainingActive ( )
inline

Definition at line 468 of file RBatchGenerator.hxx.

◆ IsValidationActive()

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::IsValidationActive ( )
inline

Definition at line 474 of file RBatchGenerator.hxx.

◆ LoadChunks()

template<typename... Args>
void ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::LoadChunks ( )
inline

Main loop for loading chunks and creating batches.

The producer (loading thread) will keep loading chunks and creating batches until the end of the epoch is reached, or the generator is deactivated.

Definition at line 286 of file RBatchGenerator.hxx.

◆ NumberOfTrainingBatches()

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::NumberOfTrainingBatches ( )
inline

Definition at line 456 of file RBatchGenerator.hxx.

◆ NumberOfValidationBatches()

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::NumberOfValidationBatches ( )
inline

Definition at line 457 of file RBatchGenerator.hxx.

◆ TrainRemainderRows()

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::TrainRemainderRows ( )
inline

Definition at line 459 of file RBatchGenerator.hxx.

◆ ValidationRemainderRows()

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::ValidationRemainderRows ( )
inline

Definition at line 460 of file RBatchGenerator.hxx.

Member Data Documentation

◆ fBatchSize

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fBatchSize
private

Definition at line 58 of file RBatchGenerator.hxx.

◆ fBlockSize

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fBlockSize
private

Definition at line 59 of file RBatchGenerator.hxx.

◆ fChunkLoader

template<typename... Args>
std::unique_ptr<RChunkLoader<Args...> > ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fChunkLoader
private

Definition at line 65 of file RBatchGenerator.hxx.

◆ fChunkSize

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fChunkSize
private

Definition at line 56 of file RBatchGenerator.hxx.

◆ fCols

template<typename... Args>
std::vector<std::string> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fCols
private

Definition at line 54 of file RBatchGenerator.hxx.

◆ fDatasetLoader

template<typename... Args>
std::unique_ptr<RDatasetLoader<Args...> > ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fDatasetLoader
private

Definition at line 64 of file RBatchGenerator.hxx.

◆ fDropRemainder

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fDropRemainder
private

Definition at line 82 of file RBatchGenerator.hxx.

◆ fEpochActive

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fEpochActive {false}
private

Definition at line 92 of file RBatchGenerator.hxx.

◆ fIsActive

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fIsActive {false}
private

Definition at line 89 of file RBatchGenerator.hxx.

◆ fLoadEager

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fLoadEager
private

Definition at line 84 of file RBatchGenerator.hxx.

◆ fLoadingCondition

template<typename... Args>
std::condition_variable ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fLoadingCondition
private

Definition at line 76 of file RBatchGenerator.hxx.

◆ fLoadingMutex

template<typename... Args>
std::mutex ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fLoadingMutex
private

Definition at line 77 of file RBatchGenerator.hxx.

◆ fLoadingThread

template<typename... Args>
std::unique_ptr<std::thread> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fLoadingThread
private

Definition at line 75 of file RBatchGenerator.hxx.

◆ fMaxChunks

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fMaxChunks
private

Definition at line 57 of file RBatchGenerator.hxx.

◆ fNumTrainingChunks

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fNumTrainingChunks
private

Definition at line 99 of file RBatchGenerator.hxx.

◆ fNumTrainingEntries

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fNumTrainingEntries
private

Definition at line 96 of file RBatchGenerator.hxx.

◆ fNumValidationChunks

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fNumValidationChunks
private

Definition at line 100 of file RBatchGenerator.hxx.

◆ fNumValidationEntries

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fNumValidationEntries
private

Definition at line 97 of file RBatchGenerator.hxx.

◆ fRdfs

template<typename... Args>
std::vector<ROOT::RDF::RNode> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fRdfs
private

Definition at line 73 of file RBatchGenerator.hxx.

◆ fReplacement

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fReplacement
private

Definition at line 87 of file RBatchGenerator.hxx.

◆ fSampledTrainingDataset

template<typename... Args>
RFlat2DMatrix ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fSampledTrainingDataset
private

Definition at line 109 of file RBatchGenerator.hxx.

◆ fSampledValidationDataset

template<typename... Args>
RFlat2DMatrix ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fSampledValidationDataset
private

Definition at line 110 of file RBatchGenerator.hxx.

◆ fSampleRatio

template<typename... Args>
float ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fSampleRatio
private

Definition at line 86 of file RBatchGenerator.hxx.

◆ fSampleType

template<typename... Args>
std::string ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fSampleType
private

Definition at line 85 of file RBatchGenerator.hxx.

◆ fSetSeed

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fSetSeed
private

Definition at line 60 of file RBatchGenerator.hxx.

◆ fShuffle

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fShuffle
private

Definition at line 83 of file RBatchGenerator.hxx.

◆ fTensorOperators

template<typename... Args>
std::unique_ptr<RFlat2DMatrixOperators> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fTensorOperators
private

Definition at line 71 of file RBatchGenerator.hxx.

◆ fTrainChunkTensor

template<typename... Args>
RFlat2DMatrix ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fTrainChunkTensor
private

Definition at line 112 of file RBatchGenerator.hxx.

◆ fTrainingBatchLoader

template<typename... Args>
std::unique_ptr<RBatchLoader> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fTrainingBatchLoader
private

Definition at line 66 of file RBatchGenerator.hxx.

◆ fTrainingChunkNum

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fTrainingChunkNum {0}
private

Definition at line 79 of file RBatchGenerator.hxx.

◆ fTrainingDataset

template<typename... Args>
RFlat2DMatrix ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fTrainingDataset
private

Definition at line 106 of file RBatchGenerator.hxx.

◆ fTrainingDatasets

template<typename... Args>
std::vector<RFlat2DMatrix> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fTrainingDatasets
private

Definition at line 103 of file RBatchGenerator.hxx.

◆ fTrainingEpochActive

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fTrainingEpochActive {false}
private

Definition at line 93 of file RBatchGenerator.hxx.

◆ fTrainingSampler

template<typename... Args>
std::unique_ptr<RSampler> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fTrainingSampler
private

Definition at line 68 of file RBatchGenerator.hxx.

◆ fUseWholeFile

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fUseWholeFile
private

Definition at line 90 of file RBatchGenerator.hxx.

◆ fValidationBatchLoader

template<typename... Args>
std::unique_ptr<RBatchLoader> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fValidationBatchLoader
private

Definition at line 67 of file RBatchGenerator.hxx.

◆ fValidationChunkNum

template<typename... Args>
std::size_t ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fValidationChunkNum {0}
private

Definition at line 80 of file RBatchGenerator.hxx.

◆ fValidationChunkTensor

template<typename... Args>
RFlat2DMatrix ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fValidationChunkTensor
private

Definition at line 114 of file RBatchGenerator.hxx.

◆ fValidationDataset

template<typename... Args>
RFlat2DMatrix ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fValidationDataset
private

Definition at line 107 of file RBatchGenerator.hxx.

◆ fValidationDatasets

template<typename... Args>
std::vector<RFlat2DMatrix> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fValidationDatasets
private

Definition at line 104 of file RBatchGenerator.hxx.

◆ fValidationEpochActive

template<typename... Args>
bool ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fValidationEpochActive {false}
private

Definition at line 94 of file RBatchGenerator.hxx.

◆ fValidationSampler

template<typename... Args>
std::unique_ptr<RSampler> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fValidationSampler
private

Definition at line 69 of file RBatchGenerator.hxx.

◆ fValidationSplit

template<typename... Args>
float ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fValidationSplit
private

Definition at line 62 of file RBatchGenerator.hxx.

◆ fVecSizes

template<typename... Args>
std::vector<std::size_t> ROOT::Experimental::Internal::ML::RBatchGenerator< Args >::fVecSizes
private

Definition at line 55 of file RBatchGenerator.hxx.

  • tree/ml/inc/ROOT/ML/RBatchGenerator.hxx