Deep Learning Algorithm Implementations 1.0.0
C++ implementations of fundamental deep learning algorithms
Loading...
Searching...
No Matches
dl::utils::Dataset< T > Class Template Reference

#include <data_loader.hpp>

Public Member Functions

 Dataset ()
 Default constructor for empty dataset.
 
 Dataset (const MatrixD &features, const MatrixD &labels)
 Constructor with feature and label matrices.
 
void add_sample (const std::vector< T > &feature, const std::vector< T > &label)
 Add a single sample to the dataset.
 
size_t size () const
 Get the number of samples in the dataset.
 
std::pair< MatrixD, MatrixDget_batch (size_t start_idx, size_t batch_size) const
 Extract a batch of samples from the dataset.
 
void shuffle ()
 Randomly shuffle the dataset samples.
 

Detailed Description

template<typename T>
class dl::utils::Dataset< T >

Definition at line 52 of file data_loader.hpp.

Constructor & Destructor Documentation

◆ Dataset() [1/2]

template<typename T >
dl::utils::Dataset< T >::Dataset ( )

Default constructor for empty dataset.

Examples
/home/runner/work/deep-learning-algo-impls/deep-learning-algo-impls/include/utils/data_loader.hpp.

Definition at line 15 of file data_loader.cpp.

◆ Dataset() [2/2]

template<typename T >
dl::utils::Dataset< T >::Dataset ( const MatrixD features,
const MatrixD labels 
)

Constructor with feature and label matrices.

Parameters
featuresMatrix containing input features (samples x features)
labelsMatrix containing target labels (samples x outputs)
Note
Features and labels must have the same number of rows (samples)

Definition at line 18 of file data_loader.cpp.

Member Function Documentation

◆ add_sample()

template<typename T >
void dl::utils::Dataset< T >::add_sample ( const std::vector< T > &  feature,
const std::vector< T > &  label 
)

Add a single sample to the dataset.

Parameters
featureFeature vector for the sample
labelLabel vector for the sample
Note
This method dynamically grows the dataset
Examples
/home/runner/work/deep-learning-algo-impls/deep-learning-algo-impls/include/utils/data_loader.hpp.

Definition at line 26 of file data_loader.cpp.

◆ get_batch()

template<typename T >
std::pair< MatrixD, MatrixD > dl::utils::Dataset< T >::get_batch ( size_t  start_idx,
size_t  batch_size 
) const

Extract a batch of samples from the dataset.

Parameters
start_idxStarting index for the batch
batch_sizeNumber of samples in the batch
Returns
Pair of (features, labels) matrices for the batch
Note
If start_idx + batch_size exceeds dataset size, returns samples from start_idx to the end
Examples
/home/runner/work/deep-learning-algo-impls/deep-learning-algo-impls/include/utils/data_loader.hpp.

Definition at line 38 of file data_loader.cpp.

◆ shuffle()

template<typename T >
void dl::utils::Dataset< T >::shuffle ( )

Randomly shuffle the dataset samples.

Note
Maintains correspondence between features and labels
Examples
/home/runner/work/deep-learning-algo-impls/deep-learning-algo-impls/include/utils/data_loader.hpp.

Definition at line 52 of file data_loader.cpp.

◆ size()

template<typename T >
size_t dl::utils::Dataset< T >::size ( ) const

Get the number of samples in the dataset.

Returns
Number of samples
Examples
/home/runner/work/deep-learning-algo-impls/deep-learning-algo-impls/include/utils/data_loader.hpp.

Definition at line 32 of file data_loader.cpp.


The documentation for this class was generated from the following files: