Lab 8: Advanced Neuron Functionality#
The objectives of this lab are:
To read in a 1D data signal in Nengo that represents a baseline response to a stimulus
Implement a learning rule to show how an animal reduces its response to a repeated, benign stimulus (aka habituation)
Main Specs:
◻ Filename changed to reflect last name of person submitting assignment
◻ Code runs error free
◻ Jupyter notebook is saved such that outputs appear upon opening file (and therefore on gradescope)
◻ Comment non-trivial code
◻ (On your honor) All markdown and resources read thoroughly and fully understood
Background#
Habituation: This is a form of learning where an animal learns to ignore a stimulus that is neither harmful nor beneficial. For instance, a loud noise may startle a creature initially, but after repeated exposure to the same noise without any negative consequences, the creature’s response diminishes.
For this lab, you will import a baseline stimulus response where the animal hears the loud noise three times. When you plot the data, you should notice that the amplitude of the response is the same every time. This would be the animal’s response if no learning occurred.
You will then implement a learning rule to gradually reduce the animal’s response to the stimuli, meaning that by the time the animal hears the noise the third time, the amplitude of the response after learning should be much smaller.
Import your Libraries#
Code Block Specs:
◻ Import all required libraries to implement your lab
Load Data#
Download your data by clicking here and save the *.csv file into the same folder as this lab.
The first column of the data file is the time, the second is the amplitude of the signal. The signal is measured every 1ms, so the samples will align perfectly with the Nengo simulator, meaning you won’t have to do any tricks to grab the right time when it’s time to pull it into Nengo. Meaning that if you use the readData
function from the the Advanced Examples tutorial, you will simply feed it the second column of data. You’re welcome!
Read the *.csv file into this notebook using pd.read_csv
(we’ve used this before!) such that you save off the second column as your input data. If you’re confused, take a look at your variables from the tutorial compared to what you are generating for your data.
Code Block Specs:
◻ Load 1D time-varying signal into Jupyter notebook (not into Nengo yet)
Utilize the readData
function to view your data using a Nengo node. Take a look at the first column of your imported data to know for how long to run your simulator. Use your Nengo node to visualize your data (i.e. probe, run, and plot).
Code Block Specs:
◻ Build a Nengo node that utilizes the classreadData
to pull the time-varying signal into Nengo
◻ Probe your node
◻ Run your simulator for the appropriate amount of time (based on downloaded data!)
◻ Plot the output of your Node
Implement Learning to Reduce the Response#
We will start with the same Nengo model structure as we did in the tutorial: [Input] —> (A) —> (B) —> [Output]
You can also reference the image in our OneNote lecture notes. (A) and (B) are both neuron ensembles. The output of (A) will be the neuron representation of the input (i.e. the same as the node output but a little noisier). The output of (B) will start out by looking the same as the output of (A). You will add an error ensemble and use the PES learning rule to “push” the output of (B) toward a very small or no response.
HOWEVER, we won’t be minimizing the difference between A and B like we did in class (think through why!! A and B are already the same - will our decoders change if the error is 0??).
You will instead need to build a neuron node and respective ensemble (C), which will reqpresent your desired output. Use ensemble (C) in conjunction with your error ensemble to “push” the output of (B) toward your desired response!
Think through what your desired response for habituation might be: eventually, if the fire alarm goes off enough times without an actual fire, we learn to ignore it. What would that function look like?
In the end, you will have an input represented by ensemble (A), and you will train the decoders for (B) in real time to reduce the response to the repeated stimuli.
Build your model and run for the appropriate amount of time.
Code Block Specs:
◻ Build a Nengo node with your desired response to the stimulus
◻ Build Nengo ensembles (A), (B), and (C)
◻ Implement the PES learning rule (just like the tutorial)
◻ Build a Nengo ensemble for your error
◻ Make the correct connections to push the output of (B) toward that of (C) - use the tutorial as a guide
◻ Probe ensembles (A), (B), and (C)
◻ Probe the decoders between (A) and (B)
View Results#
Plot your outputs of ensembles A, B, and C. Plot a few decoders to see how they evolve over time.
Code Block Specs:
◻ Run your simulator for the appropriate amount of time (based on downloaded data!)
◻ Plot the output of ensembles (A), (B), and (C)
◻ Plot three decoders to see the learning occur over time
◻ Ensure there is a legend on each plot