Documentation
¶
Overview ¶
Package gobrain provides basic neural networks algorithms.
Index ¶
- type Activation32
- type Config32
- type Context32
- type FeedForward
- func (nn *FeedForward) BackPropagate(targets []float64, lRate, mFactor float64) float64
- func (nn *FeedForward) Init(inputs, hiddens, outputs int)
- func (nn *FeedForward) SetContexts(nContexts int, initValues [][]float64)
- func (nn *FeedForward) Test(patterns [][][]float64)
- func (nn *FeedForward) Train(patterns [][][]float64, iterations int, lRate, mFactor float64, debug bool) []float64
- func (nn *FeedForward) Update(inputs []float64) []float64
- func (nn *FeedForward) UpdateWithNoise(inputs []float64, noise [][]float64) []float64
- type FeedForward32
- func (nn *FeedForward32) BackPropagate(targets []float32, lRate, mFactor float32) float32
- func (nn *FeedForward32) HalfUpdate(inputs []float32) []float32
- func (nn *FeedForward32) Init(inputs, hiddens, outputs int)
- func (nn *FeedForward32) SetContexts(nContexts int, initValues [][]float32)
- func (nn *FeedForward32) SetTanhActivation()
- func (nn *FeedForward32) SetWeights(weights []float32)
- func (nn *FeedForward32) Test(patterns [][][]float32)
- func (nn *FeedForward32) Train(patterns [][][]float32, iterations int, lRate, mFactor float32, debug bool) []float32
- func (nn *FeedForward32) TrainWithConfig(patterns [][][]float32, config Config32) []float32
- func (nn *FeedForward32) Update(inputs []float32) []float32
- func (nn *FeedForward32) UpdateWithNoise(inputs []float32, noise [][]float32) []float32
- type RNN32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Activation32 ¶
type Context32 ¶
type Context32 struct {
Iterations int
LRate, MFactor float32
Debug bool
Activations []Activation32
}
type FeedForward ¶
type FeedForward struct {
// Number of input, hidden and output nodes
NInputs, NHiddens, NOutputs int
// Whether it is regression or not
Regression bool
// Activations for nodes
InputActivations, HiddenActivations, OutputActivations []float64
// ElmanRNN contexts
Contexts [][]float64
// Weights
InputWeights, OutputWeights [][]float64
// Last change in weights for momentum
InputChanges, OutputChanges [][]float64
// Set for dropout
Dropout float64
}
FeedForwad struct is used to represent a simple neural network
func (*FeedForward) BackPropagate ¶
func (nn *FeedForward) BackPropagate(targets []float64, lRate, mFactor float64) float64
The BackPropagate method is used, when training the Neural Network, to back propagate the errors from network activation.
func (*FeedForward) Init ¶
func (nn *FeedForward) Init(inputs, hiddens, outputs int)
Initialize the neural network;
the 'inputs' value is the number of inputs the network will have, the 'hiddens' value is the number of hidden nodes and the 'outputs' value is the number of the outputs of the network.
func (*FeedForward) SetContexts ¶
func (nn *FeedForward) SetContexts(nContexts int, initValues [][]float64)
Set the number of contexts to add to the network.
By default the network do not have any context so it is a simple Feed Forward network, when contexts are added the network behaves like an Elman's SRN (Simple Recurrent Network).
The first parameter (nContexts) is used to indicate the number of contexts to be used, the second parameter (initValues) can be used to create custom initialized contexts.
If 'initValues' is set, the first parameter 'nContexts' is ignored and the contexts provided in 'initValues' are used.
When using 'initValues' note that contexts must have the same size of hidden nodes + 1 (bias node).
func (*FeedForward) Test ¶
func (nn *FeedForward) Test(patterns [][][]float64)
func (*FeedForward) Train ¶
func (nn *FeedForward) Train(patterns [][][]float64, iterations int, lRate, mFactor float64, debug bool) []float64
This method is used to train the Network, it will run the training operation for 'iterations' times and return the computed errors when training.
func (*FeedForward) Update ¶
func (nn *FeedForward) Update(inputs []float64) []float64
The Update method is used to activate the Neural Network.
Given an array of inputs, it returns an array, of length equivalent of number of outputs, with values ranging from 0 to 1.
func (*FeedForward) UpdateWithNoise ¶
func (nn *FeedForward) UpdateWithNoise(inputs []float64, noise [][]float64) []float64
type FeedForward32 ¶
type FeedForward32 struct {
// Number of input, hidden and output nodes
NInputs, NHiddens, NOutputs int
// Whether it is regression or not
Regression bool
// Activations for nodes
InputActivations, HiddenActivations, OutputActivations []float32
// ElmanRNN contexts
Contexts [][]float32
// Weights
InputWeights, OutputWeights [][]float32
// Last change in weights for momentum
InputChanges, OutputChanges [][]float32
// Set for dropout
Dropout float32
// Activation function
Activation func(x float32) float32
DActivation func(y float32) float32
}
FeedForwad struct is used to represent a simple neural network
func (*FeedForward32) BackPropagate ¶
func (nn *FeedForward32) BackPropagate(targets []float32, lRate, mFactor float32) float32
The BackPropagate method is used, when training the Neural Network, to back propagate the errors from network activation.
func (*FeedForward32) HalfUpdate ¶
func (nn *FeedForward32) HalfUpdate(inputs []float32) []float32
func (*FeedForward32) Init ¶
func (nn *FeedForward32) Init(inputs, hiddens, outputs int)
Initialize the neural network;
the 'inputs' value is the number of inputs the network will have, the 'hiddens' value is the number of hidden nodes and the 'outputs' value is the number of the outputs of the network.
func (*FeedForward32) SetContexts ¶
func (nn *FeedForward32) SetContexts(nContexts int, initValues [][]float32)
Set the number of contexts to add to the network.
By default the network do not have any context so it is a simple Feed Forward network, when contexts are added the network behaves like an Elman's SRN (Simple Recurrent Network).
The first parameter (nContexts) is used to indicate the number of contexts to be used, the second parameter (initValues) can be used to create custom initialized contexts.
If 'initValues' is set, the first parameter 'nContexts' is ignored and the contexts provided in 'initValues' are used.
When using 'initValues' note that contexts must have the same size of hidden nodes + 1 (bias node).
func (*FeedForward32) SetTanhActivation ¶
func (nn *FeedForward32) SetTanhActivation()
func (*FeedForward32) SetWeights ¶
func (nn *FeedForward32) SetWeights(weights []float32)
func (*FeedForward32) Test ¶
func (nn *FeedForward32) Test(patterns [][][]float32)
func (*FeedForward32) Train ¶
func (nn *FeedForward32) Train(patterns [][][]float32, iterations int, lRate, mFactor float32, debug bool) []float32
This method is used to train the Network, it will run the training operation for 'iterations' times and return the computed errors when training.
func (*FeedForward32) TrainWithConfig ¶
func (nn *FeedForward32) TrainWithConfig(patterns [][][]float32, config Config32) []float32
func (*FeedForward32) Update ¶
func (nn *FeedForward32) Update(inputs []float32) []float32
The Update method is used to activate the Neural Network.
Given an array of inputs, it returns an array, of length equivalent of number of outputs, with values ranging from 0 to 1.
func (*FeedForward32) UpdateWithNoise ¶
func (nn *FeedForward32) UpdateWithNoise(inputs []float32, noise [][]float32) []float32
type RNN32 ¶
type RNN32 struct {
// Number of input, hidden and output nodes
NInputs, NHiddens, NOutputs int
// Whether it is regression or not
Regression bool
// Activations for nodes
InputActivations, HiddenActivations []float32
// Weights
InputWeights [][]float32
// contains filtered or unexported fields
}