network

package
v0.0.0-...-a31b887 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2018 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NeuralNetwork

type NeuralNetwork struct {
	// contains filtered or unexported fields
}

NeuralNetwork describes a single hidden layer MLP feed forward neural network.

func New

func New(numberOfInputs, numberOfHiddenNeurons, numberOfOutputs int, learningRate float64, hiddenLayerActivationFunctionName, outputLayerActivationFunctionName string) (*NeuralNetwork, error)

New creates a new neural network.

func (*NeuralNetwork) CalculateError

func (network *NeuralNetwork) CalculateError(targetOutput []float64) (float64, error)

CalculateError function generates the error value for the given target output against the network's last output.

func (*NeuralNetwork) CalculateNewHiddenLayerWeights

func (network *NeuralNetwork) CalculateNewHiddenLayerWeights() error

CalculateNewHiddenLayerWeights function calculates new weights from the input layer to the hidden layer and bias for the hidden layer neurons, after calculating how much each weight and bias affects the error in the final output of the network. i.e. the partial differential of error with respect to the weight. ∂Error/∂Weight and the partial differential of error with respect to the bias. ∂Error/∂Bias.

By applying the chain rule, https://en.wikipedia.org/wiki/Chain_rule ∂TotalError/∂HiddenNeuronWeight = ∂TotalError/∂HiddenNeuronOutput * ∂HiddenNeuronOutput/∂TotalNetInputToHiddenNeuron * ∂TotalNetInputToHiddenNeuron/∂HiddenNeuronWeight

func (*NeuralNetwork) CalculateNewOutputLayerWeights

func (network *NeuralNetwork) CalculateNewOutputLayerWeights(outputs, targetOutputs []float64) error

CalculateNewOutputLayerWeights function calculates new weights from the hidden layer to the output layer and bias for the output layer neurons, after calculating how much each weight and bias affects the total error in the final output of the network. i.e. the partial differential of error with respect to the weight. ∂Error/∂Weight and the partial differential of error with respect to the bias. ∂Error/∂Bias.

By applying the chain rule, https://en.wikipedia.org/wiki/Chain_rule ∂TotalError/∂OutputNeuronWeight = ∂TotalError/∂TotalNetInputToOutputNeuron * ∂TotalNetInputToOutputNeuron/∂OutputNeuronWeight

func (*NeuralNetwork) CalculateOutput

func (network *NeuralNetwork) CalculateOutput(input []float64) []float64

CalculateOutput function returns the output array from the neural network for the given input array based on the current weights.

func (*NeuralNetwork) HiddenLayer

func (network *NeuralNetwork) HiddenLayer() *layer.Layer

HiddenLayer returns a pointer to the network's hidden layer.

func (*NeuralNetwork) LastOutput

func (network *NeuralNetwork) LastOutput() []float64

LastOutput function returns the array of last output computed by the network.

func (*NeuralNetwork) OutputLayer

func (network *NeuralNetwork) OutputLayer() *layer.Layer

OutputLayer returns a pointer to the network's output layer.

func (*NeuralNetwork) UpdateWeights

func (network *NeuralNetwork) UpdateWeights()

UpdateWeights updates the weights and biases for the hidden and output layer neurons with the new weights and biases.

Jump to

Keyboard shortcuts

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