core

package
v0.0.0-...-8ed5a8e Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EMPTY_DATA = NewData([3]int{0, 0, 0})

Functions

This section is empty.

Types

type Context

type Context interface {
	Forward(prev Context)
	Backward(next Context)

	GetOutput() Data       // o
	GetErrorToInput() Data // ∂E / ∂a
}

type Data

type Data struct {
	Value [][][]float64 // chan * x * y
	Size  Size
}

func NewData

func NewData(size Size) Data

func (Data) ForEach

func (d Data) ForEach(f func(value float64))

func (Data) ForEachIndex

func (d Data) ForEachIndex(f func(i, j, k int, value float64))

func (Data) Map

func (d Data) Map(f func(value float64) float64)

func (Data) MapIndex

func (d Data) MapIndex(f func(i, j, k int, value float64) float64)

type Desc

type Desc interface {
	Brief() string
	Full() string
}

type Describable

type Describable interface {
	Desc() Desc
}

type EndLayer

type EndLayer struct {
	ErrorFunc LossFunc
	Target    Data

	Input        Data
	TotalError   float64 // E
	ErrorToInput Data    // ∂E/∂a
}

func NewEndLayer

func NewEndLayer(errorFunc LossFunc, target Data) *EndLayer

func (*EndLayer) Backward

func (e *EndLayer) Backward(next Context)

func (*EndLayer) Desc

func (e *EndLayer) Desc() Desc

func (*EndLayer) Forward

func (e *EndLayer) Forward(prev Context)

func (*EndLayer) GetErrorToInput

func (e *EndLayer) GetErrorToInput() Data

func (*EndLayer) GetOutput

func (e *EndLayer) GetOutput() Data

func (*EndLayer) GetOutputSize

func (e *EndLayer) GetOutputSize() Size

func (*EndLayer) Init

func (e *EndLayer) Init(prev, next Layer)

func (*EndLayer) Learn

func (e *EndLayer) Learn(ctxs []Context)

func (*EndLayer) NewContext

func (e *EndLayer) NewContext() Context

func (*EndLayer) ToResult

func (e *EndLayer) ToResult() Result

type Layer

type Layer interface {
	Describable
	Init(prev, next Layer)
	Learn(ctxs []Context)
	NewContext() Context
	GetOutputSize() Size
}

type LossFunc

type LossFunc interface {
	Describable
	CalcLoss(target, actual Data) (error float64, partial Data) // ∂E/∂a
}

type Model

type Model struct {
	Name      string
	Layers    []Layer
	ErrorFunc LossFunc
	InputSize Size
}

func (*Model) Brief

func (m *Model) Brief() string

func (*Model) Feed

func (m *Model) Feed(input, target Data) Result

func (*Model) FeedBatch

func (m *Model) FeedBatch(dataStream <-chan TrainData, batchSize int) <-chan Result

func (*Model) Full

func (m *Model) Full() string

func (*Model) Init

func (m *Model) Init()

func (*Model) Load

func (m *Model) Load(reader io.Reader) (err error)

func (*Model) LoadFromFile

func (m *Model) LoadFromFile(file string) (err error)

func (*Model) Predict

func (m *Model) Predict(input Data) Data

func (*Model) Save

func (m *Model) Save(writer io.Writer) (err error)

func (*Model) SaveToFile

func (m *Model) SaveToFile(file string) (err error)

Persistent

func (*Model) Test

func (m *Model) Test(input, target Data) Result

type Result

type Result struct {
	Output     Data
	Target     Data
	TotalError float64
}

type SimpleDesc

type SimpleDesc struct {
	Name   string
	Core   interface{}
	Params map[string]interface{}
}

func (SimpleDesc) Brief

func (s SimpleDesc) Brief() string

func (SimpleDesc) Full

func (s SimpleDesc) Full() string

type Size

type Size [3]int

func (Size) Desc

func (s Size) Desc() Desc

func (Size) GetCount

func (s Size) GetCount() int

type StartLayer

type StartLayer struct {
	Input Data
}

func NewStartLayer

func NewStartLayer(input Data) *StartLayer

func (*StartLayer) Backward

func (s *StartLayer) Backward(next Context)

func (*StartLayer) Desc

func (s *StartLayer) Desc() Desc

func (*StartLayer) Forward

func (s *StartLayer) Forward(prev Context)

func (*StartLayer) GetErrorToInput

func (s *StartLayer) GetErrorToInput() Data

func (*StartLayer) GetOutput

func (s *StartLayer) GetOutput() Data

func (*StartLayer) GetOutputSize

func (s *StartLayer) GetOutputSize() Size

func (*StartLayer) Init

func (s *StartLayer) Init(prev, next Layer)

func (*StartLayer) Learn

func (s *StartLayer) Learn(ctxs []Context)

func (*StartLayer) NewContext

func (s *StartLayer) NewContext() Context

type TrainData

type TrainData struct {
	Input, Target Data
}

Jump to

Keyboard shortcuts

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