18 #ifndef TMVA_DNN_DATALOADER 19 #define TMVA_DNN_DATALOADER 48 template <
typename AArchitecture>
53 using Matrix_t =
typename AArchitecture::Matrix_t;
72 template<
typename Data_t,
typename AArchitecture>
class TDataLoader;
82 template<
typename Data_t,
typename AArchitecture>
93 : fDataLoader(dataLoader), fBatchIndex(index)
120 template<
typename Data_t,
typename AArchitecture>
147 size_t nInputFeatures,
size_t nOutputFeatures,
size_t nStreams = 1);
181 template<
typename AArchitecture>
191 template<
typename Data_t,
typename AArchitecture>
193 const Data_t &
data,
size_t nSamples,
size_t batchSize,
194 size_t nInputFeatures,
size_t nOutputFeatures,
size_t nStreams)
195 : fData(data), fNSamples(nSamples), fBatchSize(batchSize),
196 fNInputFeatures(nInputFeatures), fNOutputFeatures(nOutputFeatures),
197 fBatchIndex(0), fNStreams(nStreams), fDeviceBuffers(), fHostBuffers(),
216 template<
typename Data_t,
typename AArchitecture>
229 HostBuffer_t inputHostBuffer = hostBuffer.GetSubBuffer(0, inputMatrixSize);
230 HostBuffer_t outputHostBuffer = hostBuffer.GetSubBuffer(inputMatrixSize,
233 DeviceBuffer_t inputDeviceBuffer = deviceBuffer.GetSubBuffer(0, inputMatrixSize);
234 DeviceBuffer_t outputDeviceBuffer = deviceBuffer.GetSubBuffer(inputMatrixSize,
239 CopyInput(inputHostBuffer, sampleIndexIterator, fBatchSize);
240 CopyOutput(outputHostBuffer, sampleIndexIterator, fBatchSize);
242 deviceBuffer.CopyFrom(hostBuffer);
243 Matrix_t inputMatrix(inputDeviceBuffer, fBatchSize, fNInputFeatures);
244 Matrix_t outputMatrix(outputDeviceBuffer, fBatchSize, fNOutputFeatures);
251 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