Documentation
¶
Index ¶
- Constants
- Variables
- func ArgMax(xx []Deepfloat64) int
- func Fibonacci() func() int
- func Float64(a Deepfloat64) float64
- type BinaryCrossEntropy
- type Config
- type CrossEntropy
- type Deepfloat64
- func Add(a, b Deepfloat64) Deepfloat64
- func Copy(a Deepfloat64) Deepfloat64
- func DF(f float64) Deepfloat64
- func Div(a, b Deepfloat64) Deepfloat64
- func Mul(a, b Deepfloat64) Deepfloat64
- func Round(x Deepfloat64) Deepfloat64
- func Sub(a, b Deepfloat64) Deepfloat64
- func Sum(xx []Deepfloat64) (sum Deepfloat64)
- func TotalError(E []Deepfloat64) Deepfloat64
- type Dump
- type Example
- type Examples
- type KafnRand
- type Layer
- type Loss
- type LossType
- type MeanSquared
- type Neural
- func (n *Neural) ApplySynapses(points [][]Point)
- func (n *Neural) ApplyWeights(weights [][][][]Deepfloat64)
- func (n *Neural) Check() string
- func (n *Neural) Dot(path string) error
- func (n *Neural) DrawPS(path_prefix string)
- func (n *Neural) Dump() *Dump
- func (n *Neural) Forward(input []Deepfloat64) error
- func (n *Neural) ForwardT(input []Deepfloat64, trapolation tabulatedfunction.Trapolation) error
- func (n *Neural) Marshal() ([]byte, error)
- func (n *Neural) Net(path string) error
- func (n *Neural) NumWeights() (num int)
- func (n *Neural) Polinate()
- func (n *Neural) Predict(input []Deepfloat64) []Deepfloat64
- func (n *Neural) Save(path string) error
- func (n *Neural) SaveReadable(path string) error
- func (n *Neural) Smooth()
- func (n *Neural) String() string
- func (n *Neural) Synapses() [][]Point
- func (n *Neural) Trapolate(input []Deepfloat64, trapolation tabulatedfunction.Trapolation) []Deepfloat64
- func (n *Neural) Weights() [][][][]Deepfloat64
- type Neuron
- type OnlineTrainer
- type Point
- type StatsPrinter
- type Synapse
- type SynapseAnalytic
- func (s *SynapseAnalytic) AddPoint(x, y Deepfloat64, it uint32)
- func (s *SynapseAnalytic) Clear()
- func (s *SynapseAnalytic) DrawPS(path string)
- func (s *SynapseAnalytic) Epoch(uint32)
- func (s *SynapseAnalytic) Fire(value Deepfloat64)
- func (s *SynapseAnalytic) FireDerivative() Deepfloat64
- func (s *SynapseAnalytic) FireT(value Deepfloat64, trapolation tabulatedfunction.Trapolation)
- func (s *SynapseAnalytic) GetGradient(D_E_x Deepfloat64, k int) Deepfloat64
- func (s *SynapseAnalytic) GetIn() Deepfloat64
- func (s *SynapseAnalytic) GetOut() Deepfloat64
- func (s *SynapseAnalytic) GetPoint(i int) (Deepfloat64, Deepfloat64)
- func (s *SynapseAnalytic) GetTag() string
- func (s *SynapseAnalytic) GetUp() *Neuron
- func (s *SynapseAnalytic) GetWeight(k int) Deepfloat64
- func (s *SynapseAnalytic) GetWeights() []Deepfloat64
- func (s *SynapseAnalytic) Len() int
- func (s *SynapseAnalytic) Polinate(m Synapse)
- func (s *SynapseAnalytic) Refire()
- func (s *SynapseAnalytic) SetTag(tag string)
- func (s *SynapseAnalytic) SetWeight(k int, weight Deepfloat64)
- func (s *SynapseAnalytic) SetWeights(w []Deepfloat64)
- func (s *SynapseAnalytic) Smooth()
- func (s *SynapseAnalytic) String() string
- func (s *SynapseAnalytic) Trapolate(x Deepfloat64, trapolation tabulatedfunction.Trapolation) Deepfloat64
- func (s *SynapseAnalytic) WeightsString() string
- type SynapseTabulated
- func (s *SynapseTabulated) AddPoint(x, y Deepfloat64, it uint32)
- func (s *SynapseTabulated) Clear()
- func (s *SynapseTabulated) DrawPS(path string)
- func (s *SynapseTabulated) Epoch(epoch uint32)
- func (s *SynapseTabulated) Fire(value Deepfloat64)
- func (s *SynapseTabulated) FireDerivative() Deepfloat64
- func (s *SynapseTabulated) FireT(value Deepfloat64, trapolation tabulatedfunction.Trapolation)
- func (s *SynapseTabulated) GetGradient(D_E_x Deepfloat64, k int) Deepfloat64
- func (s *SynapseTabulated) GetIn() Deepfloat64
- func (s *SynapseTabulated) GetOut() Deepfloat64
- func (s *SynapseTabulated) GetPoint(i int) (Deepfloat64, Deepfloat64)
- func (s *SynapseTabulated) GetTag() string
- func (s *SynapseTabulated) GetUp() *Neuron
- func (s *SynapseTabulated) GetWeight(k int) Deepfloat64
- func (s *SynapseTabulated) GetWeights() []Deepfloat64
- func (s *SynapseTabulated) Len() int
- func (s *SynapseTabulated) Polinate(m Synapse)
- func (s *SynapseTabulated) Refire()
- func (s *SynapseTabulated) RefireT(trapolation tabulatedfunction.Trapolation)
- func (s *SynapseTabulated) SetTag(tag string)
- func (s *SynapseTabulated) SetWeight(k int, weight Deepfloat64)
- func (s *SynapseTabulated) SetWeights(w []Deepfloat64)
- func (s *SynapseTabulated) Smooth()
- func (s *SynapseTabulated) String() string
- func (s *SynapseTabulated) Trapolate(x Deepfloat64, trapolation tabulatedfunction.Trapolation) Deepfloat64
- func (s *SynapseTabulated) WeightsString() string
- type SynapseType
- type Trainer
Constants ¶
const Eps = 1e-16
Smallest number
const Leps = 1e-20
const MinIterations = 5
Minimal number of iterations
Variables ¶
var Rand = NewRand()
Functions ¶
func Fibonacci ¶
func Fibonacci() func() int
fibonacci returns a function that returns successive fibonacci numbers from each successive call
func Float64 ¶
func Float64(a Deepfloat64) float64
Types ¶
type BinaryCrossEntropy ¶
type BinaryCrossEntropy struct{}
BinaryCrossEntropy is binary CE loss
func (BinaryCrossEntropy) Cf ¶
func (l BinaryCrossEntropy) Cf(estimate, ideal [][]Deepfloat64) Deepfloat64
Cf is CE(...)
func (BinaryCrossEntropy) Df ¶
func (l BinaryCrossEntropy) Df(estimate, ideal Deepfloat64) Deepfloat64
Df is CE'(...)
func (BinaryCrossEntropy) F ¶
func (l BinaryCrossEntropy) F(estimate, ideal Deepfloat64) Deepfloat64
F is MSE(...)
type Config ¶
type Config struct {
// Number of inputs
Inputs int
// Number of outputs
Outputs int
// Loss functions: {LossCrossEntropy, LossBinaryCrossEntropy, LossMeanSquared}
Loss LossType
// Error/Loss precision
LossPrecision int
// Specifies basis size
Degree int
// Specify Synap Tags for the input layer
InputTags []string
// Number of training iterations
Epoch uint32
// If Smooth() need to be executed before each training iteration
Smooth bool
// TrapolationLinear by default
Trapolation tabulatedfunction.Trapolation
}
Config defines the network topology, activations, losses etc
type CrossEntropy ¶
type CrossEntropy struct{}
CrossEntropy is CE loss
func (CrossEntropy) Cf ¶
func (l CrossEntropy) Cf(estimate, ideal [][]Deepfloat64) Deepfloat64
Cf is CE(...)
func (CrossEntropy) Df ¶
func (l CrossEntropy) Df(estimate, ideal Deepfloat64) Deepfloat64
Df is CE'(...)
func (CrossEntropy) F ¶
func (l CrossEntropy) F(estimate, ideal Deepfloat64) Deepfloat64
F is MSE(...)
type Deepfloat64 ¶
type Deepfloat64 = float64
func Add ¶
func Add(a, b Deepfloat64) Deepfloat64
func Copy ¶
func Copy(a Deepfloat64) Deepfloat64
func DF ¶
func DF(f float64) Deepfloat64
func Div ¶
func Div(a, b Deepfloat64) Deepfloat64
func Mul ¶
func Mul(a, b Deepfloat64) Deepfloat64
func Sub ¶
func Sub(a, b Deepfloat64) Deepfloat64
func TotalError ¶
func TotalError(E []Deepfloat64) Deepfloat64
type Dump ¶
type Dump struct {
Config *Config
Weights [][][][]Deepfloat64
Activations [][]Point
Synapses [][]Point
}
Dump is a neural network dump
type Example ¶
type Example struct {
Input []Deepfloat64
Response []Deepfloat64
}
Example is an input-target pair
type Examples ¶
type Examples []Example
Examples is a set of input-output pairs
type KafnRand ¶
type KafnRand struct {
// contains filtered or unexported fields
}
func (*KafnRand) NormFloat64 ¶
type Layer ¶
type Layer struct {
Number int
S SynapseType
Neurons []*Neuron
}
Layer is a set of neurons and corresponding activation
func NewLayer ¶
func NewLayer(l, n int, synapse SynapseType) *Layer
NewLayer creates a new layer with n nodes
func (*Layer) Connect ¶
Connect fully connects layer l to next, and initializes each synapse with the given weight function func (l *Layer) Connect(next *Layer, degree int, weight WeightType) {
func (*Layer) CreateInputSynapses ¶
CreateInputSynapses create input synapses for the bottom layer
func (*Layer) FireT ¶
func (l *Layer) FireT(trapolation tabulatedfunction.Trapolation)
type Loss ¶
type Loss interface {
F(estimate, ideal Deepfloat64) Deepfloat64
Cf(estimate, ideal [][]Deepfloat64) Deepfloat64
Df(estimate, ideal Deepfloat64) Deepfloat64
}
Loss is satisfied by loss functions
type LossType ¶
type LossType int
LossType represents a loss function
const ( // LossNone signifies unspecified loss LossNone LossType = 0 // LossCrossEntropy is cross entropy loss LossCrossEntropy LossType = 1 // LossBinaryCrossEntropy is the special case of binary cross entropy loss LossBinaryCrossEntropy LossType = 2 // LossMeanSquared is MSE LossMeanSquared LossType = 3 )
type MeanSquared ¶
type MeanSquared struct{}
MeanSquared in MSE loss
func (MeanSquared) Cf ¶
func (l MeanSquared) Cf(estimate, ideal [][]Deepfloat64) Deepfloat64
Cf is MSE(...)
func (MeanSquared) Df ¶
func (l MeanSquared) Df(estimate, ideal Deepfloat64) Deepfloat64
Df is MSE'(...)
func (MeanSquared) F ¶
func (l MeanSquared) F(estimate, ideal Deepfloat64) Deepfloat64
F is MSE(...)
type Neural ¶
type Neural struct {
Layers []*Layer
Config *Config
TotalError Deepfloat64
}
Neural is a neural network
func (*Neural) ApplySynapses ¶
func (*Neural) ApplyWeights ¶
func (n *Neural) ApplyWeights(weights [][][][]Deepfloat64)
ApplyWeights sets the weights from a four-dimensional slice
func (*Neural) Forward ¶
func (n *Neural) Forward(input []Deepfloat64) error
Forward computes a forward pass
func (*Neural) ForwardT ¶
func (n *Neural) ForwardT(input []Deepfloat64, trapolation tabulatedfunction.Trapolation) error
ForwardT computes a forward pass with trapolation
func (*Neural) NumWeights ¶
NumWeights returns the number of weights in the network
func (*Neural) Predict ¶
func (n *Neural) Predict(input []Deepfloat64) []Deepfloat64
Predict computes a forward pass and returns a prediction
func (*Neural) SaveReadable ¶
Save saves network in readable JSON into the file specified
func (*Neural) Trapolate ¶
func (n *Neural) Trapolate(input []Deepfloat64, trapolation tabulatedfunction.Trapolation) []Deepfloat64
Trapolate computes a forward pass with trapolation and returns a prediction
func (*Neural) Weights ¶
func (n *Neural) Weights() [][][][]Deepfloat64
Weights returns all weights in sequence
type Neuron ¶
type Neuron struct {
In []Synapse
Out []Synapse
Ideal Deepfloat64
Sum Deepfloat64
MinSum, MaxSum Deepfloat64
}
Neuron is a neural network node
type OnlineTrainer ¶
type OnlineTrainer struct {
// contains filtered or unexported fields
}
OnlineTrainer is a basic, online network trainer
func NewTrainer ¶
func NewTrainer(precision, verbosity, parallelism int) *OnlineTrainer
NewTrainer creates a new trainer
func (*OnlineTrainer) Save ¶
func (t *OnlineTrainer) Save(path string) error
Save() saves internal of the trainer in readable JSON into file specified
func (*OnlineTrainer) SetPrefix ¶
func (t *OnlineTrainer) SetPrefix(prefix string)
Set new output prtefix
type StatsPrinter ¶
type StatsPrinter struct {
// contains filtered or unexported fields
}
StatsPrinter prints training progress
func NewStatsPrinter ¶
func NewStatsPrinter(precision int) *StatsPrinter
NewStatsPrinter creates a StatsPrinter
func (*StatsPrinter) PrintProgress ¶
func (p *StatsPrinter) PrintProgress(n *Neural, validation Examples, elapsed time.Duration, iteration uint32)
PrintProgress prints the current state of training
func (*StatsPrinter) SetPrefix ¶
func (p *StatsPrinter) SetPrefix(prefix string)
SetPrefix set new prefix
type Synapse ¶
type Synapse interface {
Refire()
Fire(Deepfloat64)
FireT(Deepfloat64, tabulatedfunction.Trapolation)
FireDerivative() Deepfloat64
SetTag(string)
GetTag() string
SetWeight(int, Deepfloat64)
GetGradient(Deepfloat64, int) Deepfloat64
GetWeight(int) Deepfloat64
String() string
WeightsString() string
GetIn() Deepfloat64
GetOut() Deepfloat64
Len() int
SetWeights([]Deepfloat64)
GetWeights() []Deepfloat64
GetUp() *Neuron
Epoch(uint32)
AddPoint(x, y Deepfloat64, it uint32)
Trapolate(x Deepfloat64, trapolation tabulatedfunction.Trapolation) Deepfloat64
GetPoint(i int) (Deepfloat64, Deepfloat64)
DrawPS(path string)
Smooth()
Polinate(Synapse)
Clear()
}
Synapse is an edge between neurons
type SynapseAnalytic ¶
type SynapseAnalytic struct {
Weights []Deepfloat64
Up *Neuron
In, Out Deepfloat64
Tag string
}
func NewSynapseAnalytic ¶
func NewSynapseAnalytic(up *Neuron, degree int, init_weights []Deepfloat64, tag string) *SynapseAnalytic
NewSynapseAnalytic returns a synapse with the weigths preset with specified initializer and marked with specified tag
func (*SynapseAnalytic) AddPoint ¶
func (s *SynapseAnalytic) AddPoint(x, y Deepfloat64, it uint32)
func (*SynapseAnalytic) Clear ¶
func (s *SynapseAnalytic) Clear()
func (*SynapseAnalytic) DrawPS ¶
func (s *SynapseAnalytic) DrawPS(path string)
func (*SynapseAnalytic) Epoch ¶
func (s *SynapseAnalytic) Epoch(uint32)
func (*SynapseAnalytic) Fire ¶
func (s *SynapseAnalytic) Fire(value Deepfloat64)
func (*SynapseAnalytic) FireDerivative ¶
func (s *SynapseAnalytic) FireDerivative() Deepfloat64
func (*SynapseAnalytic) FireT ¶
func (s *SynapseAnalytic) FireT(value Deepfloat64, trapolation tabulatedfunction.Trapolation)
func (*SynapseAnalytic) GetGradient ¶
func (s *SynapseAnalytic) GetGradient(D_E_x Deepfloat64, k int) Deepfloat64
func (*SynapseAnalytic) GetIn ¶
func (s *SynapseAnalytic) GetIn() Deepfloat64
func (*SynapseAnalytic) GetOut ¶
func (s *SynapseAnalytic) GetOut() Deepfloat64
func (*SynapseAnalytic) GetPoint ¶
func (s *SynapseAnalytic) GetPoint(i int) (Deepfloat64, Deepfloat64)
GetPoint() returns (0,0,1)
func (*SynapseAnalytic) GetTag ¶
func (s *SynapseAnalytic) GetTag() string
func (*SynapseAnalytic) GetUp ¶
func (s *SynapseAnalytic) GetUp() *Neuron
func (*SynapseAnalytic) GetWeight ¶
func (s *SynapseAnalytic) GetWeight(k int) Deepfloat64
func (*SynapseAnalytic) GetWeights ¶
func (s *SynapseAnalytic) GetWeights() []Deepfloat64
func (*SynapseAnalytic) Len ¶
func (s *SynapseAnalytic) Len() int
func (*SynapseAnalytic) Polinate ¶
func (s *SynapseAnalytic) Polinate(m Synapse)
func (*SynapseAnalytic) Refire ¶
func (s *SynapseAnalytic) Refire()
func (*SynapseAnalytic) SetTag ¶
func (s *SynapseAnalytic) SetTag(tag string)
func (*SynapseAnalytic) SetWeight ¶
func (s *SynapseAnalytic) SetWeight(k int, weight Deepfloat64)
func (*SynapseAnalytic) SetWeights ¶
func (s *SynapseAnalytic) SetWeights(w []Deepfloat64)
func (*SynapseAnalytic) Smooth ¶
func (s *SynapseAnalytic) Smooth()
func (*SynapseAnalytic) String ¶
func (s *SynapseAnalytic) String() string
func (*SynapseAnalytic) Trapolate ¶
func (s *SynapseAnalytic) Trapolate(x Deepfloat64, trapolation tabulatedfunction.Trapolation) Deepfloat64
func (*SynapseAnalytic) WeightsString ¶
func (s *SynapseAnalytic) WeightsString() string
type SynapseTabulated ¶
type SynapseTabulated struct {
Up *Neuron
In, Out Deepfloat64
Tag string
// contains filtered or unexported fields
}
func NewSynapseTabulated ¶
func NewSynapseTabulated(c *Config, up *Neuron, tag string) *SynapseTabulated
NewSynapseTabulated returns a tabulated function synapse preset with specific tag
func (*SynapseTabulated) AddPoint ¶
func (s *SynapseTabulated) AddPoint(x, y Deepfloat64, it uint32)
func (*SynapseTabulated) Clear ¶
func (s *SynapseTabulated) Clear()
func (*SynapseTabulated) DrawPS ¶
func (s *SynapseTabulated) DrawPS(path string)
func (*SynapseTabulated) Epoch ¶
func (s *SynapseTabulated) Epoch(epoch uint32)
func (*SynapseTabulated) Fire ¶
func (s *SynapseTabulated) Fire(value Deepfloat64)
func (*SynapseTabulated) FireDerivative ¶
func (s *SynapseTabulated) FireDerivative() Deepfloat64
func (*SynapseTabulated) FireT ¶
func (s *SynapseTabulated) FireT(value Deepfloat64, trapolation tabulatedfunction.Trapolation)
func (*SynapseTabulated) GetGradient ¶
func (s *SynapseTabulated) GetGradient(D_E_x Deepfloat64, k int) Deepfloat64
func (*SynapseTabulated) GetIn ¶
func (s *SynapseTabulated) GetIn() Deepfloat64
func (*SynapseTabulated) GetOut ¶
func (s *SynapseTabulated) GetOut() Deepfloat64
func (*SynapseTabulated) GetPoint ¶
func (s *SynapseTabulated) GetPoint(i int) (Deepfloat64, Deepfloat64)
GetPoint() returns n-th point in Tabulated activation
func (*SynapseTabulated) GetTag ¶
func (s *SynapseTabulated) GetTag() string
func (*SynapseTabulated) GetUp ¶
func (s *SynapseTabulated) GetUp() *Neuron
func (*SynapseTabulated) GetWeight ¶
func (s *SynapseTabulated) GetWeight(k int) Deepfloat64
func (*SynapseTabulated) GetWeights ¶
func (s *SynapseTabulated) GetWeights() []Deepfloat64
func (*SynapseTabulated) Len ¶
func (s *SynapseTabulated) Len() int
func (*SynapseTabulated) Polinate ¶
func (s *SynapseTabulated) Polinate(m Synapse)
func (*SynapseTabulated) Refire ¶
func (s *SynapseTabulated) Refire()
func (*SynapseTabulated) RefireT ¶
func (s *SynapseTabulated) RefireT(trapolation tabulatedfunction.Trapolation)
func (*SynapseTabulated) SetTag ¶
func (s *SynapseTabulated) SetTag(tag string)
func (*SynapseTabulated) SetWeight ¶
func (s *SynapseTabulated) SetWeight(k int, weight Deepfloat64)
func (*SynapseTabulated) SetWeights ¶
func (s *SynapseTabulated) SetWeights(w []Deepfloat64)
func (*SynapseTabulated) Smooth ¶
func (s *SynapseTabulated) Smooth()
func (*SynapseTabulated) String ¶
func (s *SynapseTabulated) String() string
func (*SynapseTabulated) Trapolate ¶
func (s *SynapseTabulated) Trapolate(x Deepfloat64, trapolation tabulatedfunction.Trapolation) Deepfloat64
func (*SynapseTabulated) WeightsString ¶
func (s *SynapseTabulated) WeightsString() string
type SynapseType ¶
type SynapseType int
const ( // SynapseAnalytic is an analytical function SynapseTypeAnalytic SynapseType = 0 // SynapseTabulated is a tabulated function SynapseTypeTabulated SynapseType = 1 )