Intelligent or Not? An Implementation of Aplysia’s Biological Memory in Code

Roy Li
7 min readApr 2, 2017

--

We are our memories: who we love, what we fear, our goals, our habits, our souls. Before I went to college, I did not know what programming meant, now I write code for a living. This is the net result of what I remembered during the course of 5 years. So what changed? Why these two different me are so dramatically different in terms of skill set and many other things? Hopefully it’s not contentious to say that something has changed in my brain, there has been some physical changes my brain A from 5 years ago has gone through to the brain B that is writing this down right now. If we imagine a little far back to when I was just born, the changes my brain has gone through from then represents my personality, my world view and everything else that constitues my identity. It’s the same for you as well. The different changes our brains have experienced produced the variety among us. This change is what we usually refer to as memory.

Before we dive in further, let me state that if you do not have knowledge in programming and very basic (high school) biology, it’s likely that it will take some time for you to follow the discussion. Neurons are in many ways the fundamental primitive of any mental processes including memory, here I assume that you have basic understanding of what they are.

Memory is the hallmark of intelligence, it forms the very foundation of our ability to learn from experience. How can you learn if you forget them immediately after? Today I would like to argue that all seemingly intelligent behaviors such as memory are nothing more than high level abstractions based on very simple primitives that can be understood independently and easily. More importantly, I want to illustrate that we can build systems that exhibit the same “intelligent” behavior in code even when the system is running on silicon.

Our understanding of biological memory is no where near being done, that being said, tremendous amount of progress has been made in the past century. In animals, memory exists in many forms, the ones mentioned above are largely declarative memory: faces, concepts, places, objects, they are so called because you can generally verbally describe (declare) them. Declarative memory are very high level of abstractions and relatively less understood. Our focus today is on what’s called non-declarative memory, one example is that once you learned how to ride a bicycle, you don’t need to consciously recall these knowledge while riding a bike.

The simplicity of neural system of invertebrate animals made them the perfect targets from which to learn the biological processes underpinning non-declarative memory. The marine snail Aplysia has a very simple brain that consist of about 20,000 neural cells, compared with 100 billions cells in a mammalian brain. There are 3 kinds of non-declarative memories: habituation, sensitization and classical conditioning. We will focus on the simplest form habituation and leave others to following articles. Habituation happens on human as well, a good example might be when you study in a coffee shop, at first you will notice the conversations and noises around you, but very quickly you are able to ignore them and concentrate on the tasks at hand. This process of learning to ignore innocuous stimulus is habitation. If you think about it, however simple this memory might seem to you, it’s actually extremely important from a survival point of view, it allows animals to focus the limited mental resources on important tasks like looking for preys, finding mates and, of course, finishing homework.

A little Aplysia anatomy before we dive in. Apylsia has an external organ called gill and it’s used for respiration. There is a continuation on Apysia’s mantle shell called siphon. When siphon is gently touched, the siphon will retract and at the same time the gill with withdraw into the mantle shell. The respiratory gill is obviously important for Aplysia and this mechanism has evolved protect it. The habituation happens when repeated gentle, innocuous touches are applied to the siphon.

“After one training session of 10 stumble applied to the siphon, an animal shows very little or no reaction to the tenth stimulus: a touch to the siphon will now cause little or no withdrawal of either the siphon or the gill.” — Larry R. Squire, Eric R. Kandel. Memory. From Mind to Molecules

The habituation is temporary though, it will last only 10 to 15 minutes. There is also a way to form prolonged habituation but it leverages different physiological mechanisms and is outside of scope for today’s discussion.

What is the biological machinery Aplysia is leveraging in order to learn to ignore the harmless stimulus on the siphon. Before we answer this question, let’s define 3 types of neuron: sensory neuron, motor neuron and interneuron. Sensory neuron “senses” the outside world by receiving the external stimulation and propagates the signal inward to interneurons (sometimes, it can connect to motor neurons directly). Interneurons act sort of like a relay and passes along the signal, please note that this is an aggressively simplified picture, in the real world the interneuron might participate in elaborate information processing as well. Motor neuron receives the signals from upstream, if the signal is strong enough to reach certain threshold, motor neuron will tell muscle cells to move in certain ways. The real details of connection between neurons are less important than the fact that all the neurons are pre-wired before we start to stimulate Aplysia. Here we can see an interesting paradox: if the cells are wired beforehand and stay fixed, how can Aplysia behave differently before and after certain experience? There are essentially two possibilities. Firstly, the wiring changes physically. Secondly, the strength of the wiring changes with experience. As it turns out, both are true and important in different kind of memories. In the case of habituation, we shall see that it’s the variation in connection strength that enables the learning behavior.

When siphon is touched, the sensory neurons in siphon will launch excitatory synaptic potentials, consequently, the connected interneurons and gill motor neurons are strongly excited, therefore gill will withdraw significantly. What can be clearly observed is that if such stimulation were to be repeated for several times, the magnitude of gill withdrawal would decrease noticeably. Based on studies carried out by Castellucci, Kandel and their colleagues, we now know that the decreased response is due to the weakening in synaptic connections between cells that connect siphon to gill, which means when siphon is touched again the sensory neuron (and subsequent neurons along the chain) will emit less vigorous action potential, thus the receiving interneuron and motor neurons will be stimulated less potently, and therefore the withdrawal of gill appears to be much weaker. Neural transmitters that carry signal from presynaptic membrane of the sensory neuron to the postsynaptic membrane of the interneuron are encapsulated in small vesicles. These vesicles are finite and can only be replenished at a certain rate. When repeated stimulation are incurred on sensory neurons or interneurons, the vesicles are continuously being depleted. This depletion, along with some other mechanisms , contributes to the weakening response of downstream neurons because the neural transmitter released by action potential are becoming less and less concentrated. This explained the observation that the gill withdrawal becomes less and less vigorous.

The habituation is obviously advantageous evolutionarily because responding to stimuli takes energy, learning to ignore innocuous stimuli to preserve limited resources seems to be a very smart strategy. It’s fascinating to see that such intelligent and profoundly important behavior is based on such a simple principle. What’s intrigues me even more is that we can readily replicate this behavior in our code. Let’s fire up Xcode and write an app that illustrates Aplysia’s habituation.

Since we are modeling our brain’s behavior, it’s not surprising that we start with a basic Neuron class from which each kind of our neurons will subclass. For the sake of brevity, let’s be ruthlessly simplistic about the anatomy while capturing the absolute essentials. For each neuron, we define 4 properties: incomingNeurons, outgoingNeurons, releasableSynapticVesicles and a timer. IncomingNeurons and outgoingNeurons are self-explanatory, they are upstream and downstream neurons connected to the current neuron. ReleasableSynapticVesicles represents how many synaptic vesicle that are available to be released when an action potential is fired. When the neuron object is instantiated we start a timer to replenish synaptic vesicles on a regular basis. The excite method is called on the object when it receives a action potential from a upstream stimulation, the parameter magnitude captures how strongly the stimulation is. In the case of sensory neuron, the magnitude is just the how strong the tactile touches are. Neuron’s 3 subclasses differ in how the excite methods are overridden. Note that in the excite method, I calculate the output magnitude using the multiplication between input magnitude and available synaptic vesicles. This function is not meant to be mathematical accurate but it’s suitable for the fact that the output magnitude is proportional to input magnitude and number of synaptic vesicles.

If you run this app in Xcode, you can tap the button that simulates a touch on Aplasia’s siphon, you will see the output of the magnitude of gill withdrawal. If you press the button in quick succession, you will see the magnitude goes down quickly, this matches Aplysia’s habituation where the withdrawal becomes weaker and weaker. Because neurons are continuously replenishing their synaptic vesicles, if you wait for a while and press the button again you will see the magnitude has gone back up. Therefore, our little program perfectly captures the biological behavior that we long thought only animals can do.

The fact that our little program is functionally equivalent to Aplysia’s habituation leads us to the profound question of multi-realization: can the consciousness we human have be realized on other physical basis if a functional parity can be achieved? These are the questions that keep me up at night and I will certainly come back to it shortly in the future. Regardless of whether it’s possible to replicate human consciousness, we can conclude here that a seemingly intelligent behavior created by evolution is merely higher level abstraction based on very mundane primitives. Our uncanny abilities such as recognizing objects and producing/understanding languages can surely be emulated once the appropriate level of abstractions is understood and constructed.

Sample app can be found on here.

--

--