Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchSampler ¶
type BatchSampler struct {
// contains filtered or unexported fields
}
BatchSampler constructs a way to draw batches of samples.
func NewBatchSampler ¶
func NewBatchSampler(n, batchSize int, dropLast bool, shuffleOpt ...bool) (*BatchSampler, error)
NewBatchSampler creates a new BatchSampler.
func (*BatchSampler) BatchSize ¶
func (s *BatchSampler) BatchSize() int
BatchSize returns batch size.
func (*BatchSampler) Sample ¶
func (s *BatchSampler) Sample() []int
Sample implements Sampler interface
type DataLoader ¶
type DataLoader struct {
// contains filtered or unexported fields
}
DataLoader combines a dataset and a sampler and provides an iterable over the given dataset.
func NewDataLoader ¶
func NewDataLoader(data Dataset, s Sampler) (*DataLoader, error)
func (*DataLoader) HasNext ¶
func (dl *DataLoader) HasNext() bool
HasNext returns whether there is a next item in the iteration.
func (*DataLoader) Len ¶
func (dl *DataLoader) Len() int
Len returns number of samples to be iterated.
func (*DataLoader) Next ¶
func (dl *DataLoader) Next() (interface{}, error)
Next acts as iterator to return next sample(s) from dataset.
func (*DataLoader) Reset ¶
func (dl *DataLoader) Reset(shuffleOpt ...bool)
Reset reset index to start position.
type Dataset ¶
Dataset represents a set of samples and how to access a sample by its index by implementing `Item()` method.
type DatasetKind ¶
type DatasetKind int
const ( SliceDKind DatasetKind = iota MapDKind InvalidDKind )
type KFold ¶
type KFold struct {
// contains filtered or unexported fields
}
KFold represents a struct helper to split data into partitions.
type KFoldOption ¶
type KFoldOption func(*KFoldOptions)
func WithKFoldShuffle ¶
func WithKFoldShuffle(shuffle bool) KFoldOption
func WithNFolds ¶
func WithNFolds(nfolds int) KFoldOption
type KFoldOptions ¶
type KFoldOptions struct { NFolds int // number of folds Shuffle bool // whether suffling before splitting }
func NewKFoldOptions ¶
func NewKFoldOptions(options ...KFoldOption) KFoldOptions
type MapDataset ¶
type MapDataset struct {
// contains filtered or unexported fields
}
MapDataset holds samples in a map with string type keys. Dataset sorted by keys at the time of creating.
func NewMapDataset ¶
func NewMapDataset(data interface{}) (*MapDataset, error)
NewMapDataset creates a new MapDataset. func NewMapDataset(data map[string]interface{}) *MapDataset {
func (*MapDataset) DType ¶
func (ds *MapDataset) DType() reflect.Type
func (*MapDataset) Item ¶
func (ds *MapDataset) Item(idx int) (interface{}, error)
Item implements Dataset interface.
func (*MapDataset) Len ¶
func (ds *MapDataset) Len() int
type RandOption ¶
type RandOption func(*RandOptions)
func WithReplacement ¶
func WithReplacement(replacement bool) RandOption
func WithSize ¶
func WithSize(size int) RandOption
type RandOptions ¶
func NewRandOptions ¶
func NewRandOptions(options ...RandOption) RandOptions
type RandomSampler ¶
type RandomSampler struct {
// contains filtered or unexported fields
}
RandomSampler represents a method to draw a sample randomly from dataset.
func NewRandomSampler ¶
func NewRandomSampler(n int, opt ...RandOption) (*RandomSampler, error)
NewRandomSampler creates a new RandomSampler.
n : number of samples in dataset size: Optional (default=n). Size of sampling. replacement: Optional (default=false). Whether not repeated or repeated samples.
func (*RandomSampler) BatchSize ¶
func (s *RandomSampler) BatchSize() int
BatchSize implements Sampler interface. It's always return 1.
func (*RandomSampler) Sample ¶
func (s *RandomSampler) Sample() []int
Sample implements Sampler interface.
type Sampler ¶
Sampler represents an interface to draw sample from a dataset by implementing `Sample` method to generate a slice of indices of data samples.
type SequentialSampler ¶
type SequentialSampler struct {
// contains filtered or unexported fields
}
SequentialSampler represents a method to draw sample by its order in the dataset.
func NewSequentialSampler ¶
func NewSequentialSampler(n int) *SequentialSampler
NewSequentialSampler create a new SequentialSampler
n : number of samples in dataset
func (*SequentialSampler) BatchSize ¶
func (s *SequentialSampler) BatchSize() int
func (*SequentialSampler) Sample ¶
func (s *SequentialSampler) Sample() []int
Sample implements Sampler interface.
type SliceDataset ¶
type SliceDataset struct {
// contains filtered or unexported fields
}
SliceDataset is a slice of samples.
func NewSliceDataset ¶
func NewSliceDataset(data interface{}) (*SliceDataset, error)
NewSliceDataset creates a new SliceDataset.
func (*SliceDataset) DType ¶
func (ds *SliceDataset) DType() reflect.Type
func (*SliceDataset) Item ¶
func (ds *SliceDataset) Item(idx int) (interface{}, error)
Item implements Dataset interface to get a sample by its index.
func (*SliceDataset) Len ¶
func (ds *SliceDataset) Len() int