A library for constructing Neural Networks in Go, where Neurons are goroutines that communicate with each other via channels.
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:
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})
Clone repository with $ git clone git://github.com/tleyden/neurgo.git
Run tests with $ go test
To write code that uses neurgo, your code will need import "github.com/tleyden/neurgo"
as described in the API documentation
This README file
DXNN2 - Pure Erlang TPEULN (Topology & Parameter Evolving Universal Learning Network).
Handbook of Neuroevolution Through Erlang by Gene Sher.