ng

package
v0.0.0-...-814de94 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const StopTraining = -1

Variables

This section is empty.

Functions

func Measure

func Measure(net *nn.Network, batchs interface{}, metric nn.Metric, verbosity Verbosity) (ok bool, err error)

Types

type AvgLoss

type AvgLoss struct {
	Avg   float64
	Count int
	Hist  []float32
	// contains filtered or unexported fields
}

func (*AvgLoss) Add

func (a *AvgLoss) Add(val float32)

func (*AvgLoss) Last

func (a *AvgLoss) Last() float32

func (*AvgLoss) Reset

func (a *AvgLoss) Reset()

func (*AvgLoss) Value

func (a *AvgLoss) Value() float32

type Batchs

type Batchs interface {
	Next() bool
	Data() []float32
	Label() []float32
	Close() error
	Reset() error
	Randomize(seed int)
}

type Classification

type Classification struct {
	Accuracy float32
	// contains filtered or unexported fields
}

func (*Classification) Collect

func (c *Classification) Collect(data, label []float32)

func (*Classification) Reset

func (c *Classification) Reset()

func (*Classification) Satisfy

func (c *Classification) Satisfy() bool

func (*Classification) Value

func (c *Classification) Value() float32

type Dataset

type Dataset interface {
	Open(batchSize int) (Batchs, Batchs, error)
}

type Erfc

type Erfc struct {
	Accuracy float32
	// contains filtered or unexported fields
}

func (*Erfc) Collect

func (g *Erfc) Collect(data, label []float32)

func (*Erfc) Reset

func (g *Erfc) Reset()

func (*Erfc) Satisfy

func (g *Erfc) Satisfy() bool

func (*Erfc) Value

func (g *Erfc) Value() float32

type Gym

type Gym struct {
	Optimizer nn.OptimizerConf
	Loss      mx.Loss
	Input     mx.Dimension
	Epochs    int
	Dataset   Dataset
	Verbose   Verbosity
	Every     time.Duration
	Metric    nn.Metric
	State     State
	Seed      int
}

func (*Gym) Train

func (gym *Gym) Train(ctx mx.Context, nb nn.Block) (metric float32, params nn.Params, err error)

type NullState

type NullState struct {
	Metric    nn.Metric
	Epoch     int
	Optimizer nn.OptimizerConf
}

func (*NullState) FinishEpoch

func (s *NullState) FinishEpoch(net *nn.Network, test Batchs) (metric float32, satisfied bool, err error)

func (*NullState) LogBatchLoss

func (s *NullState) LogBatchLoss(loss float32) error

func (*NullState) NextEpoch

func (s *NullState) NextEpoch(maxEpochs int) (int, error)

func (*NullState) Preset

func (s *NullState) Preset(net *nn.Network) (nn.Optimizer, error)

func (*NullState) Setup

func (s *NullState) Setup(net *nn.Network, seed int) (int, error)

type State

type State interface {
	Setup(*nn.Network, int) (int, error)
	Preset(*nn.Network) (nn.Optimizer, error)
	LogBatchLoss(loss float32) error
	NextEpoch(maxEpochs int) (int, error)
	FinishEpoch(net *nn.Network, test Batchs) (float32, bool, error)
}

type Verbosity

type Verbosity int
const (
	Silent Verbosity = iota
	Printing
	Logging
)

Jump to

Keyboard shortcuts

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