18 #ifndef TMVA_DNN_DATALOADER 19 #define TMVA_DNN_DATALOADER 49 template <
typename AArchitecture>
54 using Matrix_t =
typename AArchitecture::Matrix_t;
73 template<
typename Data_t,
typename AArchitecture>
class TDataLoader;
83 template<
typename Data_t,
typename AArchitecture>
94 : fDataLoader(dataLoader), fBatchIndex(index)
121 template<
typename Data_t,
typename AArchitecture>
148 size_t nInputFeatures,
size_t nOutputFeatures,
size_t nStreams = 1);
182 template<
typename AArchitecture>
192 template<
typename Data_t,
typename AArchitecture>
194 const Data_t &
data,
size_t nSamples,
size_t batchSize,
195 size_t nInputFeatures,
size_t nOutputFeatures,
size_t nStreams)
196 : fData(data), fNSamples(nSamples), fBatchSize(batchSize),
197 fNInputFeatures(nInputFeatures), fNOutputFeatures(nOutputFeatures),
198 fBatchIndex(0), fNStreams(nStreams), fDeviceBuffers(), fHostBuffers(),
217 template<
typename Data_t,
typename AArchitecture>
230 HostBuffer_t inputHostBuffer = hostBuffer.GetSubBuffer(0, inputMatrixSize);
231 HostBuffer_t outputHostBuffer = hostBuffer.GetSubBuffer(inputMatrixSize,
234 DeviceBuffer_t inputDeviceBuffer = deviceBuffer.GetSubBuffer(0, inputMatrixSize);
235 DeviceBuffer_t outputDeviceBuffer = deviceBuffer.GetSubBuffer(inputMatrixSize,
240 CopyInput(inputHostBuffer, sampleIndexIterator, fBatchSize);
241 CopyOutput(outputHostBuffer, sampleIndexIterator, fBatchSize);
243 deviceBuffer.CopyFrom(hostBuffer);
244 Matrix_t inputMatrix(inputDeviceBuffer, fBatchSize, fNInputFeatures);
245 Matrix_t outputMatrix(outputDeviceBuffer, fBatchSize, fNOutputFeatures);
252 template<
typename Data_t,
typename AArchitecture>
TBatch< AArchitecture > operator*()
Matrix_t & GetInput()
Return the matrix representing the input data.
void CopyOutput(HostBuffer_t &buffer, IndexIterator_t begin, size_t batchSize)
Copy output matrix into the given host buffer.
TBatch< AArchitecture > GetBatch()
Return the next batch from the training set.
typename std::vector< size_t >::iterator IndexIterator_t
void CopyInput(HostBuffer_t &buffer, IndexIterator_t begin, size_t batchSize)
Copy input matrix into the given host buffer.
size_t fNStreams
Number of buffer pairs.
bool operator!=(const TBatchIterator &other)
TDataLoader< Data_t, AArchitecture > & fDataLoader
typename AArchitecture::Matrix_t Matrix_t
TBatchIterator operator++()
TBatchIterator(TDataLoader< Data_t, AArchitecture > &dataLoader, size_t index=0)
typename AArchitecture::DeviceBuffer_t DeviceBuffer_t
TBatch(Matrix_t &, Matrix_t &)
std::vector< Event * > TMVAInput_t
typename AArchitecture::Matrix_t Matrix_t
typename AArchitecture::HostBuffer_t HostBuffer_t
void Shuffle()
Shuffle the order of the samples in the batch.
TBatch & operator=(const TBatch &)=default
TDataLoader(const Data_t &data, size_t nSamples, size_t batchSize, size_t nInputFeatures, size_t nOutputFeatures, size_t nStreams=1)
std::vector< size_t > fSampleIndices
Ordering of the samples in the epoch.
Abstract ClassifierFactory template that handles arbitrary types.
std::vector< DeviceBuffer_t > fDeviceBuffers
std::vector< HostBuffer_t > fHostBuffers
Matrix_t & GetOutput()
Return the matrix representing the output data.
std::pair< const TMatrixT< Double_t > &, const TMatrixT< Double_t > & > MatrixInput_t