std1.0.0-beta-7 SafeC docs

std :: ml::datasets

Struct std::DataLoader

#include <std/ml/datasets.h> source

struct DataLoader {
    &FloatTensor x;
    &FloatTensor y;
    &heap unsigned long order;
    unsigned long n;
    unsigned long batchSize;
    unsigned long pos;
    int shuffle;
    int device;
    struct Rng rng;
}

Iterates a dataset in batches of 'batchSize' (the last one may be smaller), in a fresh random order every epoch when 'shuffle'.

Fields

§&heap unsigned long ordersource
§unsigned long nsource
§unsigned long batchSizesource
§unsigned long possource
§int shufflesource
§int devicesource

DEVICE_CPU, or where to() put the data (batches are gathered there)

§struct Rng rngsource

Methods

§int next(&Batch out)source · definition

Fills 'out' with the next batch (new tensors, in the active tensor arena if any) and returns 1, or returns 0 at the end of an epoch and rewinds (reshuffling) for the next one.

§unsigned long batches() constsource · definition

batches per epoch

§int to(int device)source · definition

Keeps the dataset on 'device' (its tensors gain a device copy, uploaded once) and gathers each batch there; 1 on success, else the loader stays on the CPU.

§void drop()source · definition
§void free() consumesource · definition

= drop()

§static struct DataLoader new( const &Dataset ds, unsigned long batchSize, int shuffle, unsigned long seed, )source · definition