Simbrain Tutorial
December 2002--for simbrain v. 0.02
Note: This is, as the date above indicates, from an old version of Simbrain. I've been asked for a tutorial a few times so I put this up, announcing it as "still 80% relevant." But it really is old and needs to be replaced. We are working on some video intros, the book is in the works, and when time permits someone will hopefully create a slick tutorial. For now, though, you might consider the quick start page instead of this one for an up-to-date (but brief) dive in to Simbrain.
Network
(Note that I will use the word "neuron" for node in what follows simply because it's a more suggestive word. This is of course an artificial neural net--a far cry from actual brain tissue or more realistic simulation try neuron or genesis).
I will take you through the process of building a simple network. To begin,
clear away the default network by pressing
at the bottom of the network panel. Note that to bring this bottom panel into
and out of site you can press the
button at the top of the panel. Try pressing
a few times to get a feel for this. Now click somewhere in the black network
panel. Where you click determines where new neurons will be laid down. Ok,
now that you've clicked somewhere, press the
button a few times. A line of neuron should "grow" out of the point
you clicked initially. Trying making a bunch of neurons at diff rent points
on the screen.
To select a neuron you click on it, to deselect you click in any blank area
of the screen. To move a neuron you simply drag it. Try moving your neurons
around a bit. Also, once you've selected a neuron you can adjust it's activation
using the up and down arrow keys. If you go below zero the neuron will turn
blue, representing an inhibited cell. To delete a neuron you select it, then
press the key.
To connect the neurons first select a "source" neuron by clicking on it, then hold the shift key down while clicking on a "target" neuron. That is, you "shift-click" from source to target neuron. A link should appear between the two with a "weight" at the target end. Try connecting some of your neurons now.
At the target end of each link a small circle should appear, representing the
weight of the connection from source to target neuron. To adjust this weight
you select it by clicking on it and press the up and down arrow keys. Note that
color is again either blue or red (inhibitory vs. excitatory ) , but that strength
is represented by size . You can delete a weight by selecting it and
pressing the button. Connections
can be made in both directions, or laid on top of one another, though in neither
case will the graphics depict this very well.
Try using these tools to build a little network. Once you've built your net
you can save it, , and of course
you can open it later
or email
it to a friend! A trading post will hopefully be on-line soon. More on network
files here.
Your network is not set in stone. You can delete, add, connect, and modify neurons at any time, even as the simulation runs.
Now that you've settled on a basic topology (pattern of nodes and connections)
, you can tweak the network in various ways. You can manually set the neurons
and weights by selecting them and pressing the up and down arrows. You can randomize
all the neurons at once with the
button ("n" is for "neuron") or randomize all the weights
at once with the
button ("w"
is for weight). You can clear all neuron and weight values with the
and
buttons, respectively.
Try banging away at these buttons to see what they do.
Now you are ready to "run" the network. I suggest that you disconnect
the network from the world by setting the network-interaction button to
and by turning the gauge off,
.
Now press the "play" button
and randomize the neurons every few seconds with
.
Note that in each case the network will quickly "settle" into a stable
state and that weights between co-active neurons will strengthen. (This is rather
impoverished sense of "learning," resulting from setting all the neurons
to random values. More robust, world-based "learning" discussed next).
Note that this is a threshold based network with Helen weights (co-active neurons strengthen the weight between them). A more general network should be available soon.
Observe the network learning as you press the
button! You can also add or delete connections while the network is running,
to watch how connections channel activation and affect learning. Every once
in a while you can reset the weights with the
button
and watch learning begin anew. Press
to stop the simulation. To proceed more slowly and carefully, you can hand set
neurons and step
the simulation
one iteration at a time.
If you are feeling fancy, try messing with the network preferences, ,
and doing the experiments above again. If you turn off decay, for example, the
net will tend to fill with activation and stay activated.
World
So far you have built and run a network. Now to connect it to the world. But
first, let's get a feel for the world by itself, leaving the network interaction
button in the off position.
Try clicking anywhere in the world component, and observe that the creature
will walk towards your clicks.
You can also use the buttons on the numeric keypad to move the creature. Also
note that as the creature moves nearer and further from objects, e.g.the gouda
cheese
, that the "input"
at the bottom of the panel changes, intensifying as it moves closer and diminishing
as it moves away. Try cruising around for a bit and getting a feel for how the
input changes. These are the mock-"sensations" that will later be
sent to your network.
The way these mock sensations are calculated is as follows. Each object has
a vector of values, a "signature," associated with it. To see or modify
this signature, shift-click on an object, say .
This vector is diminished in proportion to the creature's distance from the
object. The sum of distance-diminished signatures is the "input" to
the network at any moment.
The preferences dialogue
can be used to used to tweak the world algorithms. "Movement increment"
determines how quickly the
moves around. "Near" and "Far" distance are limits within
which the diminishment of signatures is computed. If "far" is 100
and
is 100 units away from the
closest object, then all 0's will show up in the input line. If "near"
is 50 and
is less then 50
units from the closest object, that that object's full, undiminished signature
will appear in the input line.
Although you can modify the "smell signature" of objects by shift-clicking
them and then saving the world ,
you can't currently directly alter the world. To do that, you can however open
a .wld file in /simulations/worlds and add or delete lines of text. These lines
are fairly straightforward, containing the name of an object, its location on
screen, and its smell signature with delimiters. Try hand-tweaking a world if
you like! Then save it and open it with
.
Again, feel free to email worlds! They're just text files.
OK, now we're ready to interact network and world. First, however, we have
to tell the network which neurons receive inputs and which express output, by
revisiting the build toolbar
at the bottom of the screen. To designate a neuron as an input neuron, which
receives input from the external world, select it and press the
button. You will see an input arrow pop up under the neuron you selected. Click
again and the input symbol disappear. (NOTE that you can designate as many neurons
as you like "input," but that only eight of them will currently receive
any input from the world.)
Let's stick with input for now, saving output until later. Now that you have
a few input neurons, turn on those inputs by allowing the world to talk to the
network. Click the network-interaction button a few times until the
button appears. This arrow "points" from world to network, indicating
that information will flow in that direction. Now "push" the creature
around by clicking in the world component and observe how the input neurons
are "set" to the same levels as you see at the bottom of the world.
These input "sensations" are then propagated through the network (each
time you push the creature the network
button is pressed for you ).
Now let's get the network to talk to the world. First we need output neurons
so that the network can manifest "behavior" in the world. The process
of creating output neurons is similar to that for input neurons. First, select
a neuron, then press the
button. Click a few times to observe the output arrow appearing and disappearing
on the neuron. Note that the same neuron can both take and give off output.
Create a few output neurons at a place in your network where you know there will be activity. If necessary, add extra links to your output neuron and manually strengthen them by selecting and pressing the up arrow. As with inputs, any number of outputs can be added but only eight will actually do anything.
First set the network interaction button to .
Now add some activation to the network (e.g. by pressing
)
then press the
button a few
times, iterating the network by hand. The most active output neuron (1-8) then
sends a signal to the network. Currently this "signal" is simply an
index 1-8, which will move the creature in one of 8 directions (north, northwest,
etc.). You can see this output signal at the top left of the world component.
Try hitting
to set it all in
motion, and again feel free to randomize and tweak things, to see what impact
this has on our friend
's behavior.
Now try setting network-world interaction to
so that it goes in both directions. Press play
and in effect you have a full network-world simulation running. Of course your
poor little creature probably has little to do at this point, except perhaps
running off of the screen or banging repeatedly into
.
As of yet I've just been building this tool. Soon, I hope, YOU will create a
simulation that does interesting stuff. When you do email it my way or post
on whatever trading post will be created. You can save your simulation with
SAVE in the FILE menu. Then you can send the .wld and .net files to me or your
friends.
Gauge
Now you know the basics of the simulation, and already you should have been able to see a lot--in particular, patterns of activity coursing through the network's nodes and the way those patterns of activity strengthen the weights that connect them. But there is more to see than just that, much more! To explain what I mean a short theoretical digression is called for.
One philosophical goal of neural network theory is to explain how brains represent the world. The "connectionist" answer to this question is that brains represent the world by patterns of activity across their neurons--what in Simbrain are patterns of color distributed across a bunch of nodes in the network component. One advantage of this story is that the representations can be pictured. After all, patterns of activity are vectors--ordered lists of numbers--which can be thought of as points in high-dimensional spaces. So the states the network goes through can be thought of as sequences of points in a high-dimensional space.
The value of this is that we will be able to see how the network represents the world by tracking these points in its high dimensional "activation space" (the set of all possible patterns of activity that could occur in the network). The plan is to be able to associate each activation pattern with a point in a high dimensional space,and to see the entire history of a network as a sequence of points in that space.
But there is a problem: these points are in a high-dimensional space, beyond 3 dimensions, which we can't see. This is where the gauge comes in. It is a "Sammon-Mapper", which projects from the many dimensions of the network into the 2 dimensions of the gauge panel.
Before explaining how this works, let's see it in action.
So you've got the network and world that you built above. Now let's gauge the
network as it walks around in the world. First, stop the network by pressing
and clear all the neurons with
. Also, I recommend that
you set the network interaction button to
so that you can push
around
and thereby activate the network, but not vice-versa. Clear any existing gauge
data with
. Finally, turn
the gauge on by setting the on/off button to
.
Now you're ready. Think of the creature as having just been born. It's never been in any brain (or mental) state. Now take a step, click somewhere in the world panel. You should see one green dot show up in the upper left corner of the gauge panel (unfortunately) hidden behind some text. That green dot represents the one single state the network has thus far been in, the one "thought" it has had.
OK, what about all the text? (I know you're dying to run around like crazy--go
ahead if you want, you'll see "dancing dots" in no time!--but I'll
assume you restrained yourself...). "Dimensions" tells you the dimensionality
of the high-d space, which is given by the number of neurons in your net. If
you built a network with 10 neurons, dimension should say "10". This
is a projection of 10-dimensional activation space. "Datapoints" tells
you how many unique states the network has been in thus far. In the case of
your new-born it should say
"1". I'll explain "error" and "iteration" in a
moment.
Now start walking the creature around. The "Datapoint" number should be steadily increasing as it goes through more states, and soon you should see the odd and fascinating "dance of the green dots" going full blast. More on that soon. Note that it is not with every step that you get a new state. Sometimes the creature moves around but the network doesn't change. In those cases no new datapoint is added.
The dots are indices for brain-states /thoughts. That's the big payoff for me, the philosopher. So the number of green dots on screen--the "datapoint" number--tells you how many states that brain has been in, and also how many "thoughts" or "conscious states" the creature has had. (Of course the computer program isn't having thoughts--at least not according to me--but brains do give rise to thoughts, and that's what we're simulating).
Note that the graphics algorithm isn't currently perfected, so that dots can "hide" behind one another. I.e. "datapoint" may be greater than the number of dots you actually see.
Now that there are a few dots on screen, you can think of them this way: each green dot is a thought the creature has had some time in the past. The red dot is the thought /brain-state it is having/in right now. Eventually, the dancing should stop, and you should have a set "horizon" of past thoughts the creature has had--a pattern of green dots--where the currently active thought is shown in red.
Now, what does the "shape" of this pattern of dots mean? What are really important are the inter-point distances. Points in any (metrical) space of any dimensionality maintain distances to one another (you can calculate the distance between any two such points). This counts for brain-states as understood by connectionists, and the exciting philosophical idea is that it holds for thoughts as well. So, if the brain is in two similar states, say as it smells two similar pieces of cheese, it occupies two points in brain-space that are close to one another, and also has two thoughts that are "similar" to one another.
So dots that are close to each other represent brain-states (and conscious states) that are similar to one another.
It would be nice if, as the creature walked around different objects, the gauge
showed dots being "redded" in different regions of the space. The
idea would be that as it was around
it would linger in one region of state space and then as it went over to
it would be in a completely different region of the space. But, again, I've
just finished the tool. Real results are yet to be obtained!
Here is something to play with. If while the gauge is running, you reset the
network's weights with , the
network will suddenly be in radically different states, and the dots
will really start bouncing!
How does the gauge figure out how to project the high dimensional data to 2 dimensions? Well, here is where I must explain the dancing dots, and where the theory gets thick. The basic idea is that it starts with a random guess, computes an error, and then iterates a gradient descent algorithm to minimize that error. It's kind of like fitting a line to a scatter-plot of data in 2 dimensions. You modify the slope and offset of the line until it does the best job it can of fitting the scatter plot. In this case, however, there are not two parameters (slope and offset) to modify, but 2 times # of datapoint parameters (x and y dimensions for each point on screen) to modify. For example, if there are 10 dots on the screen (10 datapoints), then 20 parameters--the x and y coordinates of each of these 10 dots--must be updated in an effort to minimize error. Hence the dancing dots.
When the dots are dancing, the Sammon mapper is trying to minimize error between
the pattern in the high dimensional space, and the pattern in the low-dimensional
space. The error is right there on the screen for you to see, as it gets lower,
and so is a representation of the number of iterations the algorithm has gone
through in its effort to minimize error. You can set the minimum error and maximum
iterations of the algorithm in the
menu. You can manually step the algorithm with the
button.
and
have the obvious meanings.
You can also save and open
your patterns, and it largely
works, but there are some bugs right now.
If you want to start over, and clear out all the datapoints, press the
button.
Note that whenever the network is in a new state, a new dot appears and the
dance begins anew. This is another of way of saying that the Sammon algorithm
is non-scalable or non-projective--it does not accommodate brand new data. To
make up for this, a triangulation algorithm can be used to figure out what the
nearest neighbors of a new state are and then to put the new state (dot) between
those nearest neighbors. To turn on triangulation press .
To turn it off press it again,
.
Note that, after turning on triangulation, that as you move the creature around
it interposes red dots between existing points, building on the template you've
already built up.