Documentation ¶
Index ¶
- Variables
- type Activation
- type DataSample
- type DataSet
- type Layer
- type Loss
- type Mutator
- type NeuralNetwork
- func (n *NeuralNetwork) Copy() *NeuralNetwork
- func (firstParent *NeuralNetwork) Crossover(secondParent *NeuralNetwork) (*NeuralNetwork, error)
- func (n *NeuralNetwork) Mutate(mutator Mutator)
- func (n *NeuralNetwork) Predict(data []float64) []float64
- func (n *NeuralNetwork) Save(filename string) error
- func (n *NeuralNetwork) SetDebugMode(b bool)
- func (n *NeuralNetwork) Train(optimizer Optimizer, dataSet DataSet, epochs int)
- type Optimizer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWeightsNotMatch is an error for when the parents don't have the same amount of weights. ErrWeightsNotMatch = errors.New("gone: parents must have the exact same amount of weights") )
Functions ¶
This section is empty.
Types ¶
type Activation ¶
type Activation struct { Name activationName F func(x float64) float64 FPrime func(x float64) float64 }
Activation is an activation function it contains the normal f(x) and the derivative f'(x)
func Softmax ¶
func Softmax() Activation
Softmax is a softmax activation function NOT IMPLEMENTED YET
type DataSample ¶
DataSample represents a single train data set
type DataSet ¶
type DataSet []DataSample
DataSet represents a slice of all the entires in a data set
type Layer ¶
type Layer struct { Nodes int Activator Activation }
Layer represents a layer in a neural network
type Loss ¶
type Loss struct { Name lossName F func(y, yHat matrigo.Matrix) float64 FPrime func(y, yHat matrigo.Matrix) matrigo.Matrix }
Loss is a loss function it contains the normal f(x) and the derivative f'(x)
type Mutator ¶
Mutator is a function for mutating genes
func GaussianMutation ¶
GaussianMutation applies a randomly distributed gaussian mutation using mutationRate which should be a number in the range [0.0, 1.0] and represents a probability for a mutation to occur
type NeuralNetwork ¶
type NeuralNetwork struct { Weights []matrigo.Matrix Biases []matrigo.Matrix Activations []matrigo.Matrix LearningRate float64 Layers []Layer DebugMode bool Loss Loss }
NeuralNetwork represents a neural network
func Load ¶
func Load(filename string) (*NeuralNetwork, error)
Load loads a neural network from a file
func New ¶
func New(learningRate float64, loss Loss, layers ...Layer) *NeuralNetwork
New creates a neural network
func (*NeuralNetwork) Copy ¶
func (n *NeuralNetwork) Copy() *NeuralNetwork
Copy makes a deep copy of the network
func (*NeuralNetwork) Crossover ¶
func (firstParent *NeuralNetwork) Crossover(secondParent *NeuralNetwork) (*NeuralNetwork, error)
Crossover applies a crossover between 2 neural networks by getting random bits of both to create a child
func (*NeuralNetwork) Mutate ¶
func (n *NeuralNetwork) Mutate(mutator Mutator)
Mutate randomly mutates some weights and biases
func (*NeuralNetwork) Predict ¶
func (n *NeuralNetwork) Predict(data []float64) []float64
Predict is the feedforward process
func (*NeuralNetwork) Save ¶
func (n *NeuralNetwork) Save(filename string) error
Save saves the neural network to a file
func (*NeuralNetwork) SetDebugMode ¶
func (n *NeuralNetwork) SetDebugMode(b bool)
SetDebugMode toggles debug mode