34#ifndef TMVA_DNN_ARCHITECTURES_REFERENCE_TENSORDATALOADER
35#define TMVA_DNN_ARCHITECTURES_REFERENCE_TENSORDATALOADER
43template <
typename AReal>
46template <
typename AData,
typename AReal>
69 TTensorDataLoader(
const AData &data,
size_t nSamples,
size_t batchSize,
size_t batchDepth,
size_t batchHeight,
70 size_t batchWidth,
size_t nOutputFeatures,
size_t nStreams = 1);
93 template<
typename RNG>
105template <
typename AData,
typename AReal>
107 size_t batchDepth,
size_t batchHeight,
size_t batchWidth,
108 size_t nOutputFeatures,
size_t )
109 : fData(data), fNSamples(nSamples), fBatchSize(batchSize), fBatchDepth(batchDepth), fBatchHeight(batchHeight),
110 fBatchWidth(batchWidth), fNOutputFeatures(nOutputFeatures), fBatchIndex(0), inputTensor(),
111 outputMatrix(batchSize, nOutputFeatures), weightMatrix(batchSize, 1), fSampleIndices()
114 inputTensor.reserve(batchDepth);
115 for (
size_t i = 0; i < batchDepth; i++) {
116 inputTensor.emplace_back(batchHeight, batchWidth);
125template <
typename AData,
typename AReal>
126template <
typename RNG>
129 std::shuffle(fSampleIndices.begin(), fSampleIndices.end(), rng);
132template <
typename AData,
typename AReal>
135 fBatchIndex %= (fNSamples / fBatchSize);
137 size_t sampleIndex = fBatchIndex * fBatchSize;
138 IndexIterator_t sampleIndexIterator = fSampleIndices.begin() + sampleIndex;
140 CopyTensorInput(inputTensor, sampleIndexIterator);
141 CopyTensorOutput(outputMatrix, sampleIndexIterator);
142 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.
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.
size_t fBatchSize
The size of a batch.
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 fBatchSize
The size of a batch.
size_t fNSamples
The total number of samples in the dataset.
TTensorDataLoader(const Data_t &data, size_t nSamples, size_t batchSize, size_t batchDepth, size_t batchHeight, size_t batchWidth, size_t nOutputFeatures, size_t nStreams=1)
Constructor.
typename std::vector< size_t >::iterator IndexIterator_t
create variable transformations