Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dataset ¶
type Dataset interface {
// Len returns the total number of samples.
Len() int
// Get returns the input and target tensors for the given index.
Get(index int) (input, target *tensor.Tensor, err error)
}
Dataset provides random access to individual samples.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader iterates over a Dataset in batches.
loader := data.NewLoader(ds, data.LoaderConfig{BatchSize: 32, Shuffle: true})
for loader.Next() {
input, target := loader.Batch()
// ... training step ...
}
if err := loader.Err(); err != nil { ... }
loader.Reset() // new epoch
func NewLoader ¶
func NewLoader(ds Dataset, cfg LoaderConfig) *Loader
NewLoader creates a Loader for the given dataset and configuration.
func (*Loader) Close ¶
func (l *Loader) Close()
Close stops background workers and releases resources. Safe to call multiple times.
type LoaderConfig ¶
type LoaderConfig struct {
BatchSize int // samples per batch (required, must be > 0)
Shuffle bool // randomize sample order each epoch
NumWorkers int // parallel fetch goroutines (0 = sequential)
PrefetchN int // batches buffered ahead (0 = no prefetch)
DropLast bool // drop incomplete final batch
Device *tensor.Device // move batches to this device after stacking (nil = no move)
}
LoaderConfig configures a Loader.
type TensorDataset ¶
type TensorDataset struct {
// contains filtered or unexported fields
}
TensorDataset wraps pre-loaded input and target tensors. Each sample is a slice along dimension 0.
func NewTensorDataset ¶
func NewTensorDataset(inputs, targets *tensor.Tensor) *TensorDataset
NewTensorDataset creates a dataset from batched tensors. Both tensors must have the same size along dimension 0.
func (*TensorDataset) Get ¶
func (d *TensorDataset) Get(index int) (input, target *tensor.Tensor, err error)
func (*TensorDataset) Len ¶
func (d *TensorDataset) Len() int
Click to show internal directories.
Click to hide internal directories.