Documentation
¶
Overview ¶
Package gobrain provides basic neural networks algorithms.
Index ¶
- 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
}
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.