All Projects → tleyden → neurgo

tleyden / neurgo

Licence: Apache-2.0 License
Neural Network toolkit in Go

Programming Languages

go
31211 projects - #10 most used programming language

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

  • Feedforward networks
  • Recurrent networks
  • JSON Marshal/Unmarshal (example json)
  • Visualization network topology in SVG (example svg)

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:

  • neurvolve - An evolution based trainer that is essentially a port of DXNN2 (a Topology & Parameter Evolving Universal Learning Network in Erlang).

Roadmap

  • Training module for Backpropagation based learning (contributions welcome!)
  • Stress testing / benchmarks

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

  • Install Go

  • 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

Documentation

Libraries that build on Neurgo

  • neurvolve builds on this library to support evolution-based learning.

Related Work

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

Related Publications

Handbook of Neuroevolution Through Erlang by Gene Sher.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].