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.
Index ¶
- func Accuracy(actual []float64, predicted []float64) (int, float64)
- func Predict(perceptron *Perceptron, stimulus *Stimulus) float64
- func RandomPerceptronInit(perceptron *Perceptron)
- func RawExpectedConversion(stimuli *Stimuli)
- func SeparateSet(stimuli *Stimuli, percentage float64, mix int)
- func TrainPerceptron(perceptron *Perceptron, stimuli *Stimuli, epochs int, init int)
- func UpdateWeights(perceptron *Perceptron, stimulus *Stimulus) (float64, float64)
- type Perceptron
- type Stimuli
- type Stimulus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Accuracy ¶
Accuracy calculate percentage of equal values between two float64 based slices. It returns int number and a float64 percentage value of corrected values.
func Predict ¶
func Predict(perceptron *Perceptron, stimulus *Stimulus) float64
Predict performs a perceptron prediction to passed stimulus. It returns a float64 binary predicted value.
func RandomPerceptronInit ¶
func RandomPerceptronInit(perceptron *Perceptron)
RandomPerceptronInit initialize perceptron weight, bias and learning rate using NormFloat64 random value.
func RawExpectedConversion ¶
func RawExpectedConversion(stimuli *Stimuli)
RawExpectedConversion converts (string) raw expected values in stimuli training / testing sets to float64 values It works on stimule struct (pointer) passed. It doens't returns nothing
func SeparateSet ¶
separateSet Stimuli training set in training and testing. TODO: create in-place rotation If passed mix is 0, training and testing set will be first merged, then splitted with given percentage. If passed mix is 1, training and testing set will be first merged, then shuffled, then splitted with given percentage.
func TrainPerceptron ¶
func TrainPerceptron(perceptron *Perceptron, stimuli *Stimuli, epochs int, init int)
TrainPerceptron trains a passed perceptron with stimuli passed, for specified number of epoch. If init is 0, leaves weights unchanged before training. If init is 1, reset weights and bias of perceptron before training.
func UpdateWeights ¶
func UpdateWeights(perceptron *Perceptron, stimulus *Stimulus) (float64, float64)
UpdateWeights performs update in perceptron weights with respect to passed stimulus. It returns error of prediction before and after updating weights.
Types ¶
type Perceptron ¶
type Perceptron struct { // Weights represents Perceptron vector representation Weights []float64 // Bias represents Perceptron natural propensity to spread signal Bias float64 // Lrate represents learning rate of perceptron Lrate float64 }
Perceptron struct represents a simple Perceptron network with a slice of n weights.
type Stimuli ¶
type Stimuli struct { // Set of stimulus for training Training []Stimulus // Set of stimulus for testing Testing []Stimulus // Percentage of strimulus for training and testing SplitPercentage float64 }
Stimuli struct represents a set of stimulus splitted in training and testing set
func LoadStimuliFromCSVFile ¶
LoadStimuliFromCSVFile load a CSV dataset into Stimuli struct. If mix is 0, no shuffling will be performed. If 1, pseudo-random shuffling of line will be performed. It returns Stimuli struct splitting record in file with passed percentage.