tleyden / neurgo

Neural Network toolkit in Go
Apache License 2.0
36 stars 3 forks source link

Neurgo

Build Status GoDoc

A library for constructing Neural Networks in Go, where Neurons are goroutines that communicate with each other via channels.

architecture_diagram.png

What it can do

Learning mechanism

Neurgo does not contain any code for learning/training.

The idea is to have a separation of concerns such that the code that does the training will live in it's own repo. Currently, there is only one training module:

Roadmap

Example applications

Example code

The following code creates a neural net with this topology. It does not actually run the network (eg, feed inputs), so for a more complete example see cortex_test.go.

sensor := &Sensor{
    NodeId:       NewSensorId("sensor", 0.0),
    VectorLength: 2,
}
sensor.Init()
hiddenNeuron1 := &Neuron{
    ActivationFunction: EncodableSigmoid(),
    NodeId:             NewNeuronId("hidden-neuron1", 0.25),
    Bias:               -30,
}
hiddenNeuron1.Init()
hiddenNeuron2 := &Neuron{
    ActivationFunction: EncodableSigmoid(),
    NodeId:             NewNeuronId("hidden-neuron2", 0.25),
    Bias:               10,
}
hiddenNeuron2.Init()
outputNeuron := &Neuron{
    ActivationFunction: EncodableSigmoid(),
    NodeId:             NewNeuronId("output-neuron", 0.35),
    Bias:               -10,
}
outputNeuron.Init()
actuator := &Actuator{
    NodeId:       NewActuatorId("actuator", 0.5),
    VectorLength: 1,
}
actuator.Init()

// wire up connections
sensor.ConnectOutbound(hiddenNeuron1)
hiddenNeuron1.ConnectInboundWeighted(sensor, []float64{20, 20})
sensor.ConnectOutbound(hiddenNeuron2)
hiddenNeuron2.ConnectInboundWeighted(sensor, []float64{-20, -20})
hiddenNeuron1.ConnectOutbound(outputNeuron)
outputNeuron.ConnectInboundWeighted(hiddenNeuron1, []float64{20})
hiddenNeuron2.ConnectOutbound(outputNeuron)
outputNeuron.ConnectInboundWeighted(hiddenNeuron2, []float64{20})
outputNeuron.ConnectOutbound(actuator)
actuator.ConnectInbound(outputNeuron)

// create cortex
nodeId := NewCortexId("cortex")
cortex := &Cortex{
    NodeId: nodeId,
}
cortex.SetSensors([]*Sensor{sensor})
cortex.SetNeurons([]*Neuron{hiddenNeuron1, hiddenNeuron2, outputNeuron})
cortex.SetActuators([]*Actuator{actuator})

Getting Started

Documentation

Libraries that build on Neurgo

Related Work

DXNN2 - Pure Erlang TPEULN (Topology & Parameter Evolving Universal Learning Network).

Related Publications

Handbook of Neuroevolution Through Erlang by Gene Sher.