Project which allow to simulate simple biological neural networks.
Below I attach the screen of a sample simulation. That simulation explains how lateral inhibition works.
- Download tar.gz file.
- Run
pip install ./path_to_file/cereblus-0.1.0.tar.gz
We have got four basic objects
Neuron
represents one neuron.Neural Network
represents network.Displayer
represents graphical interface.Stimulus
represents stimulus, which activates neurons.
Let's write
from cereblus import *
neural_network = NeuralNetwork()
n1 = neural_network.neuron(template=Receptor, pos=(300, 300, 0))
n2 = neural_network.neuron(template=Receptor, pos=(300, 400, 0))
n3 = neural_network.neuron(template=Receptor, pos=(550, 350, 0))
We've just created a network with three neurons – n1, n2 and n3. First two neurons are receptors -- they can react to the stimuli, which we will use later. n3 is standard Neuron. It is worth mentioning that all Receptor in child class of Neuron. Let's join them
n1.connect(n3, coeff=0.5)
n2.connect(n3, coeff=0.7)
Now n1 is connected to n3 with coefficient 0.5 and n2 is connected to n3 with coefficient 0.7.
We connect our network to the Displayer
displayer = Displayer(neu_net)
displayer.show()
Our network is doing exactly nothing. Why? We haven't stimulated it.
Let's create file stimulation.json
{
"num_of_pixels": 2,
"loop": true,
"phases": [
[0.5, "O-"],
[0.5, "-O"],
[1, "OO"]
]
}
And connect it to the neurons n1 and n2
stimulus = StimulationLoader.load_from_file("stimulation.json")
stimulus.connect(n1, num_of_pixel=0)
stimulus.connect(n2, num_of_pixel=1)
We can imagine it as two receptors connected to the two pixels. Pixel is active when there is 'O' in current phase, and it in inactive when it is '-'.
Now let's look on our network.
You can write your own Neurons – which for example learn and change connections. The easiest way is to inherit from the Neuron class. Look into the code to undersand how Neuron works – it is simple.