14#ifndef TMVA_RBATCHLOADER
15#define TMVA_RBATCHLOADER
24#include <condition_variable>
30namespace Experimental {
61 std::make_unique<TMVA::Experimental::RTensor<float>>(std::vector<std::size_t>{
fBatchSize - 1,
fNumColumns});
63 std::make_unique<TMVA::Experimental::RTensor<float>>(std::vector<std::size_t>{
fBatchSize - 1,
fNumColumns});
78 fCurrentBatch = std::make_unique<TMVA::Experimental::RTensor<float>>(std::vector<std::size_t>({0}));
97 fCurrentBatch = std::make_unique<TMVA::Experimental::RTensor<float>>(std::vector<std::size_t>({0}));
131 std::unique_ptr<TMVA::Experimental::RTensor<float>>
133 std::size_t batchSize)
136 std::make_unique<TMVA::Experimental::RTensor<float>>(std::vector<std::size_t>({batchSize,
fNumColumns}));
138 for (std::size_t i = 0; i < batchSize; i++) {
146 std::unique_ptr<TMVA::Experimental::RTensor<float>>
151 std::make_unique<TMVA::Experimental::RTensor<float>>(std::vector<std::size_t>({
fBatchSize,
fNumColumns}));
173 const std::vector<std::size_t>
eventIndices,
const std::size_t start = 0)
175 for (std::size_t i = start; i <
eventIndices.size(); i++) {
191 std::unique_lock<std::mutex> lock(
fBatchLock);
197 std::vector<std::unique_ptr<TMVA::Experimental::RTensor<float>>>
batches;
218 std::unique_lock<std::mutex> lock(
fBatchLock);
219 for (std::size_t i = 0; i <
batches.size(); i++) {
248 std::vector<std::size_t> idx;
250 for (std::size_t i = start; i < (start +
fBatchSize); i++) {
266 std::iota(idx.begin(), idx.end(), 0);
268 std::unique_ptr<TMVA::Experimental::RTensor<float>>
batch =
271 std::unique_lock<std::mutex> lock(
fBatchLock);
278 std::iota(idx.begin(), idx.end(), 0);
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Activate()
Activate the batchloader so it will accept chunks to batch.
std::size_t fTrainingRemainderRow
RBatchLoader(const TMVA::Experimental::RTensor< float > &chunkTensor, const std::size_t batchSize, const std::size_t numColumns, const std::size_t maxBatches)
std::unique_ptr< TMVA::Experimental::RTensor< float > > fTrainingRemainder
void CreateValidationBatches(const std::vector< std::size_t > &eventIndices)
Create validation batches from the given chunk based on the given event indices Batches are added to ...
std::size_t fValidationRemainderRow
std::unique_ptr< TMVA::Experimental::RTensor< float > > CreateFirstBatch(const TMVA::Experimental::RTensor< float > &remainderTensor, std::size_t remainderTensorRow, std::span< const std::size_t > eventIndices)
std::queue< std::unique_ptr< TMVA::Experimental::RTensor< float > > > fValidationBatchQueue
std::condition_variable fBatchCondition
void CreateTrainingBatches(const std::vector< std::size_t > &eventIndices)
Create training batches from the given chunk of data based on the given event indices Batches are add...
const TMVA::Experimental::RTensor< float > & GetTrainBatch()
Return a batch of data as a unique pointer.
const TMVA::Experimental::RTensor< float > & fChunkTensor
std::unique_ptr< TMVA::Experimental::RTensor< float > > CreateBatch(const TMVA::Experimental::RTensor< float > &chunkTensor, std::span< const std::size_t > idxs, std::size_t batchSize)
std::unique_ptr< TMVA::Experimental::RTensor< float > > fCurrentBatch
void SaveRemainingData(TMVA::Experimental::RTensor< float > &remainderTensor, const std::size_t remainderTensorRow, const std::vector< std::size_t > eventIndices, const std::size_t start=0)
save to remaining data when the whole chunk has to be saved
std::unique_ptr< TMVA::Experimental::RTensor< float > > fValidationRemainder
const TMVA::Experimental::RTensor< float > & GetValidationBatch()
Returns a batch of data for validation The owner of this batch has to be with the RBatchLoader.
void DeActivate()
DeActivate the batchloader.
std::queue< std::unique_ptr< TMVA::Experimental::RTensor< float > > > fTrainingBatchQueue
RTensor is a container with contiguous memory and shape information.
create variable transformations