34#ifndef TMVA_DNN_ARCHITECTURES_REFERENCE_TENSORDATALOADER
35#define TMVA_DNN_ARCHITECTURES_REFERENCE_TENSORDATALOADER
43template <
typename AReal>
46template <
typename AData,
typename AReal>
72 size_t batchHeight,
size_t batchWidth,
size_t nOutputFeatures,
73 std::vector<size_t> inputShape,
size_t nStreams = 1);
96 template<
typename RNG>
108template <
typename AData,
typename AReal>
110 size_t batchHeight,
size_t batchWidth,
size_t nOutputFeatures,
111 std::vector<size_t> inputShape,
size_t )
112 : fData(data), fNSamples(nSamples), fBatchDepth(batchDepth), fBatchHeight(batchHeight),
113 fBatchWidth(batchWidth), fNOutputFeatures(nOutputFeatures), fBatchIndex(0), fInputShape(std::move(inputShape)), inputTensor(),
114 outputMatrix(inputShape[0], nOutputFeatures), weightMatrix(inputShape[0], 1), fSampleIndices()
119 inputTensor.emplace_back(batchHeight, batchWidth);
128template <
typename AData,
typename AReal>
129template <
typename RNG>
132 std::shuffle(fSampleIndices.begin(), fSampleIndices.end(), rng);
135template <
typename AData,
typename AReal>
138 fBatchIndex %= (fNSamples / fInputShape[0]);
140 size_t sampleIndex = fBatchIndex * fInputShape[0];
141 IndexIterator_t sampleIndexIterator = fSampleIndices.begin() + sampleIndex;
143 CopyTensorInput(inputTensor, sampleIndexIterator);
144 CopyTensorOutput(outputMatrix, sampleIndexIterator);
145 CopyTensorWeights(weightMatrix, sampleIndexIterator);
The reference architecture class.
TTensorDataLoader & operator=(const TTensorDataLoader &)=default
TMatrixT< AReal > weightMatrix
The matrix used to keep the batch weights.
TTensorDataLoader(TTensorDataLoader &&)=default
size_t fBatchHeight
The number od rows in each matrix.
const AData & fData
The data that should be loaded in the batches.
std::vector< TMatrixT< AReal > > inputTensor
The 3D tensor used to keep the input data.
size_t fNSamples
The total number of samples in the dataset.
std::vector< size_t > fInputShape
Defines the batch depth, no. of channels and spatial dimensions of an input tensor.
void CopyTensorInput(std::vector< TMatrixT< AReal > > &tensor, IndexIterator_t sampleIterator)
Copy input tensor into the given host buffer.
std::vector< size_t > fSampleIndices
Ordering of the samples in the epoch.
size_t fBatchIndex
The index of the batch when there are multiple batches in parallel.
TMatrixT< AReal > outputMatrix
The matrix used to keep the output.
TTensorDataLoader(const TTensorDataLoader &)=default
size_t fBatchDepth
The number of matrices in the tensor.
size_t fBatchWidth
The number of columns in each matrix.
void CopyTensorWeights(TMatrixT< AReal > &matrix, IndexIterator_t sampleIterator)
Copy weight matrix into the given host buffer.
TTensorDataLoader & operator=(TTensorDataLoader &&)=default
size_t fNOutputFeatures
The number of outputs from the classifier/regressor.
void CopyTensorOutput(TMatrixT< AReal > &matrix, IndexIterator_t sampleIterator)
Copy output matrix into the given host buffer.
TTensorBatchIterator< Data_t, Architecture_t > BatchIterator_t
void Shuffle(RNG &rng)
Shuffle the order of the samples in the batch.
std::vector< size_t > fSampleIndices
Ordering of the samples in the epoch.
TTensorBatch< Architecture_t > GetTensorBatch()
Return the next batch from the training set.
size_t fBatchDepth
The number of matrices in the tensor.
size_t fNSamples
The total number of samples in the dataset.
typename std::vector< size_t >::iterator IndexIterator_t
create variable transformations