net

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogisticFunc

func LogisticFunc(x, a float64) float64

LogisticFunc returns the value of the logistic function for x and a

Types

type ActivationFunction

type ActivationFunction func(float64) float64

ActivationFunction function definition of activation functions

func NewLogisticFunc

func NewLogisticFunc(a float64) ActivationFunction

NewLogisticFunc applies and returns the Logistic function

type Criterion

type Criterion int

Criterion is needed to decide if the Engine found a better working network. It functions as decider during the training.

const (
	// Accuracy decides evaluation by accuracy
	Accuracy Criterion = iota
	// BalancedAccuracy decides evaluation by balanced accuracy
	BalancedAccuracy
	// FMeasure decides evaluation by f-measure
	FMeasure
	// Simple decides on simple wrong/correct ratio
	Simple
	// Distance decides evaluation by distance to ideal output
	Distance
)

type Enter

type Enter struct {
	OutSynapses []*Synapse
	Input       float64 `json:"-"`
}

Enter represents the input vector that comes into the network

func NewEnter

func NewEnter() *Enter

NewEnter creates a new Enter

func (*Enter) ConnectTo

func (e *Enter) ConnectTo(layer *Layer)

ConnectTo connects the Enter to the next layer (to the neurons)

func (*Enter) SetInput

func (e *Enter) SetInput(val float64)

SetInput sets the input the specific enter

func (*Enter) Signal

func (e *Enter) Signal()

Signal passes the signal into the network

func (*Enter) SynapseTo

func (e *Enter) SynapseTo(nTo *Neuron, weight float64)

SynapseTo creates a new Synapse to a Neuron from the next layer

type Layer

type Layer struct {
	Neurons []*Neuron
}

Layer holds the neurons with their synapse connections

func NewLayer

func NewLayer(neurons int) *Layer

NewLayer creats a new layer with the number of neurons given.

func (*Layer) Calculate

func (l *Layer) Calculate()

Calculate the a activation of the current layer

func (*Layer) ConnectTo

func (l *Layer) ConnectTo(layer *Layer)

ConnectTo is used to connect the neurons of one layer with the neurons of another layer.

type Network

type Network struct {
	Enters    []*Enter
	Layers    []*Layer
	Out       []float64 `json:"-"`
	OutLabels map[int]string
}

Network contains all the necessary information to use the neural network

func BuildNetwork

func BuildNetwork(usage NetworkType, input int, hidden []int, labels map[int]string) *Network

BuildNetwork builds a neural network from parameters given

func NewNetwork

func NewNetwork(in int, layers []int, labels map[int]string) *Network

NewNetwork creates a new neural network

func (*Network) Calculate

func (n *Network) Calculate(enters []float64) []float64

Calculate calculates the result of a input vector

func (*Network) CalculateLabels

func (n *Network) CalculateLabels(enters []float64) map[string]float64

CalculateLabels output with all labels of output neurons

func (*Network) CalculateWinnerLabel

func (n *Network) CalculateWinnerLabel(enters []float64) string

CalculateWinnerLabel calculates the output and just returns the label of the winning euron

func (*Network) ConnectEnters

func (n *Network) ConnectEnters()

ConnectEnters connects the input neurons with the first hidden layer

func (*Network) ConnectLayers

func (n *Network) ConnectLayers()

ConnectLayers connects all layers with corresponding neurons

func (*Network) RandomizeSynapses

func (n *Network) RandomizeSynapses()

RandomizeSynapses applies a random value to all synapses

func (*Network) SetActivationFunction

func (n *Network) SetActivationFunction(aFunc ActivationFunction)

SetActivationFunction sets the activation function for the network

type NetworkType

type NetworkType int

NetworkType represents the type of the neural network in terms of which task the network has. Classification and Regression are implemented.

const (
	// Classification describes the mode of operation: classification
	Classification NetworkType = iota
	// Regression describes the mode of operation: regression
	Regression
)

type Neuron

type Neuron struct {
	OutSynapses        []*Synapse
	InSynapses         []*Synapse         `json:"-"`
	ActivationFunction ActivationFunction `json:"-"`
	Out                float64            `json:"-"`
}

Neuron holds the neuron structure with incoming synapses, outgoing synapses, the activation function of the neuron as well as the out value.

func NewNeuron

func NewNeuron() *Neuron

NewNeuron creates a new empty neuron

func (*Neuron) Calculate

func (n *Neuron) Calculate()

Calculate calculates the actual neuron activity

func (*Neuron) SetActivationFunction

func (n *Neuron) SetActivationFunction(aFunc ActivationFunction)

SetActivationFunction sets the activation function for the neuron

func (*Neuron) SynapseTo

func (n *Neuron) SynapseTo(nTo *Neuron, weight float64)

SynapseTo creates a new synapse to a neuron

type Synapse

type Synapse struct {
	Weight float64
	In     float64 `json:"-"`
	Out    float64 `json:"-"`
}

Synapse holds the synapse structure with the weight and the In and Out neuron.

func NewSynapse

func NewSynapse(weight float64) *Synapse

NewSynapse creates a new synapse with the weight

func NewSynapseFromTo

func NewSynapseFromTo(from, to *Neuron, weight float64) *Synapse

NewSynapseFromTo creates a new synapse from neuron to neuron

func (*Synapse) Signal

func (s *Synapse) Signal(value float64)

Signal activates the Synapse with an input value

Jump to

Keyboard shortcuts

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