training

package
v0.0.0-...-79dc244 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adam

type Adam struct {
	// contains filtered or unexported fields
}

Adam is an Adam solver

func NewAdam

func NewAdam(lr, beta, beta2, epsilon float64) *Adam

NewAdam returns a new Adam solver

func (*Adam) Init

func (o *Adam) Init(size int)

Init initializes vectors using number of weights in network

func (*Adam) Update

func (o *Adam) Update(value, gradient float64, t, idx int) float64

Update returns the update for a given weight

type BatchTrainer

type BatchTrainer struct {
	// contains filtered or unexported fields
}

BatchTrainer implements parallelized batch training

func NewBatchTrainer

func NewBatchTrainer(solver Solver, verbosity, batchSize, parallelism int) *BatchTrainer

NewBatchTrainer returns a BatchTrainer

func (*BatchTrainer) Train

func (t *BatchTrainer) Train(n *deep.Neural, examples, validation Examples, iterations int)

Train trains n

type Example

type Example struct {
	Input    []float64
	Response []float64
}

Example is an input-target pair

type Examples

type Examples []Example

Examples is a set of input-output pairs

func (Examples) Shuffle

func (e Examples) Shuffle()

Shuffle shuffles slice in-place

func (Examples) Split

func (e Examples) Split(p float64) (first, second Examples)

Split assigns each element to two new slices according to probability p

func (Examples) SplitN

func (e Examples) SplitN(n int) []Examples

SplitN splits slice into n parts

func (Examples) SplitSize

func (e Examples) SplitSize(size int) []Examples

SplitSize splits slice into parts of size size

type OnlineTrainer

type OnlineTrainer struct {
	// contains filtered or unexported fields
}

OnlineTrainer is a basic, online network trainer

func NewTrainer

func NewTrainer(solver Solver, verbosity int) *OnlineTrainer

NewTrainer creates a new trainer

func (*OnlineTrainer) Train

func (t *OnlineTrainer) Train(n *deep.Neural, examples, validation Examples, iterations int)

Train trains n

type SGD

type SGD struct {
	// contains filtered or unexported fields
}

SGD is stochastic gradient descent with nesterov/momentum

func NewSGD

func NewSGD(lr, momentum, decay float64, nesterov bool) *SGD

NewSGD returns a new SGD solver

func (*SGD) Init

func (o *SGD) Init(size int)

Init initializes vectors using number of weights in network

func (*SGD) Update

func (o *SGD) Update(value, gradient float64, iteration, idx int) float64

Update returns the update for a given weight

type Solver

type Solver interface {
	Init(size int)
	Update(value, gradient float64, iteration, idx int) float64
}

Solver implements an update rule for training a NN

type StatsPrinter

type StatsPrinter struct {
	// contains filtered or unexported fields
}

StatsPrinter prints training progress

func NewStatsPrinter

func NewStatsPrinter() *StatsPrinter

NewStatsPrinter creates a StatsPrinter

func (*StatsPrinter) Init

func (p *StatsPrinter) Init(n *deep.Neural)

Init initializes printer

func (*StatsPrinter) PrintProgress

func (p *StatsPrinter) PrintProgress(n *deep.Neural, validation Examples, elapsed time.Duration, iteration int)

PrintProgress prints the current state of training

type Trainer

type Trainer interface {
	Train(n *deep.Neural, examples, validation Examples, iterations int)
}

Trainer is a neural network trainer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL