Package dimer :: Module data :: Class TrainDataset
[hide private]
[frames] | no frames]

Class TrainDataset

source code

object --+
         |
        TrainDataset
Known Subclasses:

a mixin for batch functionality, valid and train sub-dataset

Instance Methods [hide private]
 
__init__(self, batch_s, tot_s=None, valid_s=None, valid_idx=None, rng=None)
Dataset that will create train and validation batches from the given params.
source code
 
__batches(self) source code
 
__iter_batches(self, which, nepochs)
infinite loop over train/valid batches
source code
 
iter_train(self, nepochs) source code
 
iter_valid(self, nepochs) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, batch_s, tot_s=None, valid_s=None, valid_idx=None, rng=None)
(Constructor)

source code 

Dataset that will create train and validation batches from the given params.

the idea is to split the data into batches and allocate a 'valid_s' portion of them for validation. the position of the (continuous) validation block is w.r.t batches. E.g., for tot_size = 10, batch_s = 2, valid_idx=3, valid_s = 0.3 you get 4 + 1 train + valid batches: T T T V T

Parameters:
  • tot_s - nr. of examples
  • batch_s - batch size
  • valid_s - fraction of data to allocate for validation
  • valid_idx - batch index at which allocate validation data
  • rng - numpy.RandomState used to shuffle batches or None (no shuffle) @return : (train_batches, valid_batches)
Overrides: object.__init__

__iter_batches(self, which, nepochs)

source code 

infinite loop over train/valid batches

Parameters:
  • nepochs - loop this many times over train batches (0 will loop forever)
Returns:
iterator