neural

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2017 License: GPL-3.0 Imports: 10 Imported by: 2

Documentation

Overview

Neural provides struct to represents most common neural networks model and algorithms to train / test them.

Neural provides struct to represents most common neural networks model and algorithms to train / test them.

Neural provides struct to represents most common neural networks model and algorithms to train / test them.

Neural provides struct to represents most common neural networks model and algorithms to train / test them.

Neural provides struct to represents most common neural networks model and algorithms to train / test them.

Index

Constants

View Source
const (
	SCALING_FACTOR = 0.0000000000001
)

Variables

This section is empty.

Functions

func Accuracy

func Accuracy(actual []float64, predicted []float64) (int, float64)

Accuracy calculate percentage of equal values between two float64 based slices. It returns int number and a float64 percentage value of corrected values.

func BackPropagate added in v0.2.0

func BackPropagate(mlp *MultiLayerNetwork, s *Pattern, o []float64, options ...int) (r float64)

BackPropagation algorithm for assisted learning. Convergence is not guaranteed and very slow. Use as a stop criterion the average between previous and current errors and a maximum number of iterations. [mlp:MultiLayerNetwork] input value [s:Pattern] input value (scaled between 0 and 1) [o:[]float64] expected output value (scaled between 0 and 1) return [r:float64] delta error between generated output and expected output

func ElmanTrain added in v0.2.0

func ElmanTrain(mlp *MultiLayerNetwork, patterns []Pattern, epochs int)

ElmanTrain train a mlp MultiLayerNetwork with BackPropagation algorithm for assisted learning.

func Execute added in v0.2.0

func Execute(mlp *MultiLayerNetwork, s *Pattern, options ...int) (r []float64)

Execute a multi layer Perceptron neural network. [mlp:MultiLayerNetwork] multilayer perceptron network pointer, [s:Pattern] input value It returns output values by network

func HeavysideTransfer added in v0.2.0

func HeavysideTransfer(d float64) float64

func HeavysideTransferDerivate added in v0.2.0

func HeavysideTransferDerivate(d float64) float64

func HyperbolicTransfer added in v0.2.0

func HyperbolicTransfer(d float64) float64

func HyperbolicTransferDerivate added in v0.2.0

func HyperbolicTransferDerivate(d float64) float64

func MLPTrain added in v0.2.0

func MLPTrain(mlp *MultiLayerNetwork, patterns []Pattern, mapped []string, epochs int)

MLPTrain train a mlp MultiLayerNetwork with BackPropagation algorithm for assisted learning.

func Predict

func Predict(neuron *NeuronUnit, pattern *Pattern) float64

Predict performs a neuron prediction to passed pattern. It returns a float64 binary predicted value.

func RandomNeuronInit added in v0.2.0

func RandomNeuronInit(neuron *NeuronUnit, dim int)

RandomNeuronInit initialize neuron weight, bias and learning rate using NormFloat64 random value.

func RawExpectedConversion

func RawExpectedConversion(patterns []Pattern) []string

RawExpectedConversion converts (string) raw expected values in patterns training / testing sets to float64 values It works on pattern struct (pointer) passed. It doens't returns nothing

func SigmoidalTransfer added in v0.2.0

func SigmoidalTransfer(d float64) float64

func SigmoidalTransferDerivate added in v0.2.0

func SigmoidalTransferDerivate(d float64) float64

func TrainNeuron added in v0.2.0

func TrainNeuron(neuron *NeuronUnit, patterns []Pattern, epochs int, init int)

TrainNeuron trains a passed neuron with patterns passed, for specified number of epoch. If init is 0, leaves weights unchanged before training. If init is 1, reset weights and bias of neuron before training.

func UpdateWeights

func UpdateWeights(neuron *NeuronUnit, pattern *Pattern) (float64, float64)

UpdateWeights performs update in neuron weights with respect to passed pattern. It returns error of prediction before and after updating weights.

Types

type MultiLayerNetwork added in v0.2.0

type MultiLayerNetwork struct {

	// Lrate represents learning rate of neuron
	L_rate float64

	// NeuralLayers represents layer of neurons
	NeuralLayers []NeuralLayer

	// Transfer function
	T_func transferFunction

	// Transfer function derivative
	T_func_d transferFunction
}

func PrepareElmanNet added in v0.2.0

func PrepareElmanNet(i int, h int, o int, lr float64, tf transferFunction, trd transferFunction) (rnn MultiLayerNetwork)

PrepareElmanNet create a recurrent neUral network neural network. [l:[]int] is an int array with layers neurons number [input, ..., output] [lr:int] is the learning rate of neural network [tr:transferFunction] is a transfer function [tr:transferFunction] the respective transfer function derivative

func PrepareMLPNet added in v0.2.0

func PrepareMLPNet(l []int, lr float64, tf transferFunction, trd transferFunction) (mlp MultiLayerNetwork)

PrepareMLPNet create a multi layer Perceptron neural network. [l:[]int] is an int array with layers neurons number [input, ..., output] [lr:int] is the learning rate of neural network [tr:transferFunction] is a transfer function [tr:transferFunction] the respective transfer function derivative

type NeuralLayer added in v0.2.0

type NeuralLayer struct {

	// NeuronUnits represents NeuronUnits in layer
	NeuronUnits []NeuronUnit
	// Lrate represents number of NeuronUnit in layer
	Length int
}

Level struct represents a simple NeuronUnits network with a slice of n NeuronUnits.

func PrepareLayer added in v0.2.0

func PrepareLayer(n int, p int) (l NeuralLayer)

PrepareLayer create a NeuralLayer with n NeuronUnits inside [n:int] is an int that specifies the number of neurons in the NeuralLayer [p:int] is an int that specifies the number of neurons in the previous NeuralLayer It returns a NeuralLayer object

type NeuronUnit added in v0.2.0

type NeuronUnit struct {

	// Weights represents NeuronUnit vector representation
	Weights []float64
	// Bias represents NeuronUnit natural propensity to spread signal
	Bias float64
	// Lrate represents learning rate of neuron
	Lrate float64

	// Value represents desired value when loading input into network in Multi NeuralLayer Perceptron
	Value float64
	// Delta represents delta error for unit
	Delta float64
}

NeuronUnit struct represents a simple NeuronUnit network with a slice of n weights.

type Pattern added in v0.2.0

type Pattern struct {

	// Features that describe the pattern
	Features []float64
	// Raw (usually string) expected value
	SingleRawExpectation string
	// Numeric representation of expected value
	SingleExpectation float64
	// Numeric representation of expected value
	MultipleExpectation []float64
}

Pattern struct represents one pattern with dimensions and desired value

func CreateRandomPatternArray added in v0.2.0

func CreateRandomPatternArray(d int, k int) []Pattern

CreateRandomPatternArray load a CSV dataset into an array of Pattern.

func LoadPatternsFromCSVFile added in v0.2.0

func LoadPatternsFromCSVFile(filePath string) ([]Pattern, error, []string)

LoadPatternsFromCSVFile load a CSV dataset into an array of Pattern.

Jump to

Keyboard shortcuts

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