MachineIntelligenceCore:Algorithms
|
Template class storing the sample batches. A batch is stored in fact as three vectors, containing data, labels and sample numbers respectively. More...
#include <Batch.hpp>
Public Member Functions | |
Batch (size_t batch_size_=1) | |
Batch (const mic::types::Batch< DataType, LabelType > &batch_) | |
mic::types::Batch< DataType, LabelType > & | operator= (const mic::types::Batch< DataType, LabelType > &batch_) |
virtual | ~Batch () |
std::vector< std::shared_ptr < DataType > > & | data () |
Returns sample data. More... | |
std::vector< std::shared_ptr < LabelType > > & | labels () |
Returns sample labels. More... | |
std::vector< size_t > & | indices () |
Returns sample numbers (sample "positions" in original dataset). More... | |
std::shared_ptr< DataType > | data (size_t index_) |
std::shared_ptr< LabelType > | labels (size_t index_) |
std::vector< size_t > | indices (size_t index_) |
size_t | size () |
void | setBatchSize (size_t batch_size_) |
size_t | getBatchSize () |
mic::types::Batch< DataType, LabelType > | getRandomBatch () |
mic::types::Batch< DataType, LabelType > | getNextBatch () |
mic::types::Batch< DataType, LabelType > | getBatch (std::vector< size_t > indices_) |
mic::types::Batch< DataType, LabelType > | getBatchDirect (std::vector< size_t > indices_) |
bool | isLastBatch () |
mic::types::Sample< DataType, LabelType > | getRandomSample () |
mic::types::Sample< DataType, LabelType > | getNextSample () |
mic::types::Sample< DataType, LabelType > | getSample (size_t index_) |
mic::types::Sample< DataType, LabelType > | getSampleDirect (size_t index_) |
void | setNextSampleIndex (size_t index_=0) |
bool | isLastSample () |
virtual void | add (mic::types::Sample< DataType, LabelType > sample_) |
virtual void | add (std::shared_ptr< DataType > data_, std::shared_ptr< LabelType > label_, size_t index_) |
virtual void | add (std::shared_ptr< DataType > data_, std::shared_ptr< LabelType > label_) |
void | countClasses () |
size_t | classes () |
Protected Attributes | |
size_t | next_sample_index |
size_t | batch_size |
std::random_device | rd |
std::mt19937_64 | rng_mt19937_64 |
std::vector< std::shared_ptr < DataType > > | sample_data |
Stores the data. More... | |
std::vector< std::shared_ptr < LabelType > > | sample_labels |
Stores labels. More... | |
std::vector< size_t > | sample_indices |
Stores sample indices (sample "positions" in original dataset). More... | |
size_t | number_of_classes |
Template class storing the sample batches. A batch is stored in fact as three vectors, containing data, labels and sample numbers respectively.
DataType | Template parameter defining the sample data type. |
LabelType | Template parameters defining the sample label label. |
|
inline |
|
inline |
|
inlinevirtual |
|
inlinevirtual |
Adds sample to the batch.
sample_ | Sample to be added. |
Definition at line 377 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::getBatch(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::getBatchDirect().
|
inlinevirtual |
|
inlinevirtual |
|
inline |
Returns the number of distinctive classes.
Definition at line 427 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::countClasses(), and main().
|
inline |
|
inline |
|
inline |
|
inline |
Returns batch of samples with given indices. If any of the indices is out of dataset range throws an "std::out_of_range" exception.
indices_ | Vector of indices |
|
inline |
Returns batch of samples with given positions in the batch (thus they can have different indices i.e. positions in the original dataset!). If any of the indices is out of dataset range throws an "std::out_of_range" exception.
indices_ | Vector of indices |
Definition at line 242 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::getNextBatch(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::getRandomBatch().
|
inline |
|
inline |
Iterates through samples and returns them batch by batch. After returning the last possible batch from the dataset the procedure starts from the beginning. This behaviour can be avoided by manually calling the isLastBatch() method.
Definition at line 191 of file Batch.hpp.
Referenced by main().
|
inline |
Iterates through samples and returns them one by one. After returning the last element from the dataset the procedure starts from the beginning. This behaviour can be avoided by manualy calling the isLastSample() method.
|
inline |
|
inline |
|
inline |
Returns sample with given index. If index is out of batch range throws an "std::out_of_range" exception.
index_ | Sample index. |
Definition at line 309 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::getBatch().
|
inline |
Returns sample being in a given position in the batch (thus it can have different index i.e. position in the original dataset!). If index is out of batch range throws an "std::out_of_range" exception.
index_ | Sample index. |
Definition at line 338 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::getBatchDirect(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getNextSample(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::getRandomSample().
|
inline |
Returns sample numbers (sample "positions" in original dataset).
Definition at line 108 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::getNextBatch().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
protected |
Batch size. As defaults set to one.
Definition at line 440 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::Batch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getBatchSize(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getNextBatch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getRandomBatch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::isLastBatch(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::setBatchSize().
|
protected |
Index of the returned sample - it is used ONLY in getNextSample (i.e. iterative, not random sampling) method.
Definition at line 435 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::Batch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getNextBatch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getNextSample(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::isLastBatch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::isLastSample(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::setNextSampleIndex().
|
protected |
Number of distinctive classes in the (main) dataset.
Definition at line 465 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::Batch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::classes(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::countClasses(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getBatch(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::operator=().
|
protected |
|
protected |
Mersenne Twister pseudo-random generator of 32-bit numbers with a state size of 19937 bits.
Definition at line 450 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::getRandomBatch(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::getRandomSample().
|
protected |
Stores the data.
Definition at line 454 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::add(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::Batch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::data(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getNextBatch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getNextSample(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getRandomBatch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getRandomSample(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getSample(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getSampleDirect(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::isLastBatch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::isLastSample(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::operator=(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::size().
|
protected |
Stores sample indices (sample "positions" in original dataset).
Definition at line 460 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::add(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::Batch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getSample(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getSampleDirect(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::indices(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::operator=().
|
protected |
Stores labels.
Definition at line 457 of file Batch.hpp.
Referenced by mic::types::Batch< mic::types::MatrixXf, unsigned int >::add(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::Batch(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::countClasses(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getSample(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::getSampleDirect(), mic::types::Batch< mic::types::MatrixXf, unsigned int >::labels(), and mic::types::Batch< mic::types::MatrixXf, unsigned int >::operator=().