You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: Please include your numerical student ID only, do not include your name.
Note: Unlike assignments 1-4, for this assignment the full instructions (including some hints) are in this file. The cells you need to fill out are marked with a "writing hand" symbol. Of course, you can add new cells in between the instructions, but please leave the instructions intact to facilitate marking.
This assignment is worth 30 marks (30% of the final grade). The number of marks for each question is indicated in brackets to the left of each question.
Clearly label any plot you produce, including the axes. Provide a legend if there are multiple lines in the same plot.
You won’t be judged on the quality of your code.
All questions use the nengo default of Leaky Integrate-and-Fire neurons with the default parameter settings (tau_rc=0.02 and tau_ref=0.002).
Make sure to execute the Jupyter command “Restart Kernel and Run All Cells” before submitting your solutions. You will lose marks if your code fails to run or produces results that differ significantly from what you’ve submitted.
Rename the completed notebook to syde556_assignment_05_<STUDENT ID>.ipynb and submit it via email to the TA (Nicole Dumont [email protected]). The deadline is at 23:59 EST on Dec 2, 2022.
There is a late penalty of one mark per day late. Please contact [email protected] if there are extenuating circumstances.
For this assignment, you must use Nengo. Feel free to look through the examples folder and/or the tutorials on the Nengo website before doing this assignment.
# Import numpy and matplotlibimportnumpyasnpimportmatplotlib.pyplotaspltimportnengo# Fix the numpy random seed for reproducible resultsnp.random.seed(18945)
# Some formating options%configInlineBackend.figure_formats= ['svg']
1. Building an Accumulate-to-Threshold Decision Making Model
One standard account for how brains make simple decision-making tasks is that they gradually accumulate evidence for or against something, and when that evidence hits some threshold, a decision is made. This sort of model is used to account for the fact that people take longer to make decisions when the evidence is weak.
We're going to make a model of this process. It will make its choice based on a single input value, which gives some evidence as to which choice should be made. It will indicate a choice by outputting either a 1 or a -1. If that input evidence is positive, it will be more likely to make the first choice (outputting a 1), and if the input evidence is negative it will be more likely to make the second choice (outputting a -1).
TIP: The Nengo GUI built-in tutorials 10 through 18 may be useful to give you an overview of different recurrent systems and different ways of modifying Ensembles.
a) Accumulation. [2 marks] Start by building a recurrent system that can add up evidence over time (the accumulator or integrator). This is a neural Ensemble that holds a single dimension, and uses a small number of neurons (50). Provide it with one input Node that has a constant value of [0.1] and connect that input into the Ensemble with a Connection. Now make a Connection from the Ensemble back to itself that computes the identity function. Since this Connection is accumulating evidence over time, we want it to be fairly stable, so set synapse=0.1 on this Connection (leave the other Connection at its default value). This means that the neurotransmitter being used will spread out over 100ms, rather than the default 5ms.
If you run the above system with the constant positive input of 0.1 as noted above, the value stored in the accumulator should gradually increase until it hits 1 (this should take about 1 second of simulated time). If you change the input to be -0.1, it should gradually decrease until it hits -1.
Make a single plot that shows the behaviour of the model for four different inputs: 0.2, 0.1, -0.1, and -0.2. For each input, run the model for 2 seconds (sim.run(2)) and plot the value stored in the accumulator Ensemble. Use a Probe synapse of 0.01 to get the stored value.
defsimulate(
input=lambdat: 0.1ift>=0else0,
run_time=2,
title="",
n_neurons=50,
label="",
recur_synapse=1/10,
con_synapse=1/10,
probe_synapse=10/1000,
dt=1000,
noise=None,
function=None,
intercepts=None,
):
model=nengo.Network(label=label)
dimensions=1defrecur(f):
return1*fiffunction==None:
function=recuroutput=Nonewithmodel:
x=nengo.Node(input)
ensemble=nengo.Ensemble(n_neurons=n_neurons, dimensions=dimensions)
nengo.Connection(x, ensemble)
nengo.Connection(ensemble, ensemble, function=recur, synapse=recur_synapse)
iffunction!=None:
ensemble2=nengo.Ensemble(n_neurons=n_neurons, dimensions=dimensions)
ifintercepts:
ensemble2.intercepts=interceptsnengo.Connection(
ensemble, ensemble2, function=function, synapse=con_synapse
)
probe_x=nengo.Probe(x, synapse=probe_synapse)
probe_ensemble=nengo.Probe(ensemble, synapse=probe_synapse)
probe_ensemble2=Noneiffunction!=None:
probe_ensemble2=nengo.Probe(ensemble2, synapse=probe_synapse)
ifnoise:
ensemble.noise=noisesimulation=nengo.Simulator(model)
simulation.run(run_time)
t=simulation.trange()
output=simulation.data[probe_ensemble]
iffunction!=None:
output=simulation.data[probe_ensemble2]
plt.figure()
plt.suptitle(title)
b=plt.plot(t, output, label="$\hat{y(t)}$")
a=plt.plot(t, simulation.data[probe_x], label="$x(t)$")
plt.legend(
handles=[
a,
b,
],
labels=[],
)
plt.xlim([0, run_time])
plt.xlabel("$t$")
plt.show()
simulate(
input=lambdat: 0.2ift>=0else0,
title="Accumulate to Threshold decision maker with input of 0.2",
)
simulate(
input=lambdat: 0.1ift>=0else0,
title="Accumulate to Threshold decision maker with input of 0.1",
)
simulate(
input=lambdat: -0.1ift>=0else0,
title="Accumulate to Threshold decision maker with input of -0.1",
)
simulate(
input=lambdat: -0.2ift>=0else0,
title="Accumulate to Threshold decision maker with input of -0.2",
)
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("ebc5df47-009a-4766-851b-5dad2ab9b7a2");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('0ed47caa-2445-41d0-a128-1e4efb20d0d2');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("86c9f4f4-a859-4b79-9a54-7ef11cd28a57");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('fc6c71fb-8c30-43bf-a24a-f02d96bc154d');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("b0e8694a-8b70-461b-846c-e38b7fc3b295");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('2aa03042-a7ec-4882-8572-9b318b3c9ee1');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("3b603099-36af-49bc-89a7-c7b2e02f4a66");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('d645399a-32b6-4983-b7e3-641e6e4e98c2');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
b) Accumulator Discussion. [1 mark] What is the mathematical computation being performed here (i.e. what is the relationship between the input and the output)? Why does the value stop increasing (or decreasing) when it hits +1 (or -1)?
There is a linear relationship between the input and the output. That is, for every time step the the output $\hat{y_{t+1}} = \hat{y_t} + \hat{x_t}$ where $\hat{y_0}=0$ where $t=0,1,2...$ are the timesteps. This results in a linear accumulation at each timestep by the initial input. This is why it takes half the time for twice the input to reach the saturation point of the Accumulate-to-threshold model. The reason why the model does not represent values $|x| \gt 1$ is because encoders limited to values between -1 and 1. This means that the populations cannot encode or "represent" values whos magnitudes extend beyond -1 and 1.
c) Adding random noise to the neurons. [1 mark] Next, we can add randomness to the neurons. In standard (non-neural) accumulator models, there is a "random-walk" component that randomly varies the value being accumulated. We can model this by adding random noise into the Ensemble, which means adding random current to each of the neurons. The command for this is:
(where acc is whatever name you gave your accumulator Ensemble.)
The strength of this noise is set by the rms=1 parameter. Generate the same plot as in part (a) but with the noise rms=1. Also generate the same plot for rms=3, rms=5, and rms=10. What happens to the resulting output?
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("e57e14f6-2157-496a-8a1e-756c1ce1b0c8");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('a832fcf7-7923-4aa4-b06f-0ad57bccd0ac');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("1552cd3c-6a39-4807-bf1e-ff2147b3a50e");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('d08d908b-9937-496f-ae09-5e489c47652d');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("30496bad-eb8c-4976-8987-43fa3653d59a");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('84d767e3-ce15-4883-a2ee-f7749536bca9');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("bbd15981-fb30-4bf6-920e-05936d295ad3");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('9b09197c-58a2-4c2d-9e92-1130c67d2720');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("cc47c1a2-cb61-42aa-bfa2-0692472d2998");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('c19cc86f-ea8c-462e-8038-ae2d1e9591fe');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("a315b7da-b12b-4dc4-a3a1-dba5a8487cc1");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('b2355e39-8cf6-49cc-a8ef-ab81d8a46b01');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("f791109a-b156-4033-b3c6-3653e228004c");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('3214a0fa-9f98-45d6-9341-d6929610e8e6');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("f66f3f61-7b81-4f13-8f78-49ec54c4da5f");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('2a02ada1-bf28-48ce-ab96-3711450bdf90');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("b4137ee7-7e9f-43ff-b600-f57948dd5a11");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('a0ba11a9-f240-455a-a488-28ab667fbc34');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("c9e25922-7caf-49b4-a0b1-f5b45ee79639");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('ddae0e1f-5dc4-47f7-9633-a28637cc0d5c');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("d4665721-236d-4c1c-b165-ce7714953216");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('8e9e156f-c478-42bb-87d7-e2c2c6800e17');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("43989620-1c7e-41ce-9b2e-c1f1927153cd");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('8165d4a6-e014-4e27-9979-eaab66e8d41e');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("3076b6b1-efe0-4d49-8b39-3f9c26c797f8");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('be141485-8cc0-4c66-a7ae-cc78d9b7f662');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("f6533003-1251-443b-8db8-5c65d1f2b699");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('37291faa-385d-4110-9a27-0e4a8170a92c');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("50f26f05-7b42-40f7-b09d-05aaee6fc9a7");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('3cf8c08b-e0e9-4efe-a093-6c8ba3891068');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("6712c409-66aa-4021-8725-57d2b17bd4cd");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('b7397fac-acb1-4bd3-b6df-8b81eb13cbd5');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
As we can see, when we increase the RMS in the noise signal, the model performs significantly worse and does not saturate as quickly. This is due to the heavy presense of noise in the signal and behaves as we would expect. That is: as the error in the signal increases the performace decreases.
e) Adding decision-making. [2 marks] To complete the basic model, we want to determine when this accumulator passes some threshold. If the value becomes large enough, we should make one choice (+1), and if it becomes small enough we should make the other choice (-1). To achieve this, make a new output Ensemble that is also one-dimensional and has 50 neurons. Form a Connection from the accumulator to this new Ensemble that computes the following function:
This new output should now stay at zero until the accumulator value gets large enough, and then quickly move to +1 or -1.
Build this model and plot the output of both the accumulator Ensemble and the decision-making Ensemble. Use a noise rms=3 and for both Probes use a synapse of 0.01. Do this for all four input values (0.2, 0.1, -0.1, and -0.2).
How well does the system perform? Does it make decisions faster when there is stronger evidence? What differences are there (if any) between the computation we are asking the system to perform and the actual result?
TIP: try running the model a few times to see the variability in the output
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("af11a0a6-1229-431d-9d7d-6c3dc364868d");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('8f11044f-7b1d-48ef-9019-e5bf37700241');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("4666f18c-2a8c-4d94-a47d-c89fd6a7f483");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('e64a7cdc-b8e5-48f8-8237-d1fb46bc37bb');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("d821ed4e-f3f4-495f-8e90-e5c163bca244");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('eef89cd8-ae60-4b2e-b473-81a17e78cba9');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("d3af90b5-c788-4999-9909-5cf07a2d3877");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('e27659d0-a33f-4049-9502-d18feb25cc59');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
As we would expect, the model reaches a decision much quicker with the choice model as it is only considering strong evidence in it's decision causing it to reach the threshold and saturate much quicker.
f) Combining Ensembles. [2 marks] An alternative implementation would be to combine the two separate 1-dimensional Ensembles into one 2-dimensional Ensemble. The Connections are made similarly as in the original model, but they need to target the particular dimensions involved using the ens[0] and ens[1] syntax. Try building the model this way and plot the results. Do this for a single Ensemble with 100 neurons (the same number as the total number of neurons in the original model) and with 500 neurons. Also, be sure to increase the radius as would be appropriate in order to produce values like what we had in the original model, where the accumulator might be storing a 1 and the output might be a 1.
How does combining Ensembles in this way change the performance of the system?
When the Ensembles are combined together in this way, what are we changing about the biological claims about the model? In particular, how might we determine whether the real biologicial system has these as separate Ensembles or combined together?
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("f049ce24-706b-4844-b3b8-0e85ea974571");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('41ae5198-dc19-4c85-a5a9-3e80bf67f77c');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("89f13428-dc82-49cc-8a7a-7f6267152fa9");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('e2c358e0-669a-4a68-8fe7-211f46b3b025');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("2489c586-19e0-4100-b5c8-10c0f59bff74");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('f43df550-6c72-4de7-ae96-41bd073ae42d');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("95d83da7-2c37-467b-a31d-a58a98d316fb");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('a1bbd387-cb47-46fd-a4c8-17f022408004');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("951207c8-1d1f-4fec-b71c-db49b0d75a2f");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('7cd63c6b-6256-41c6-b203-5a1cd7366b0b');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("94e81a8c-c0c5-4e11-bec8-2971d572779f");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('865fe5cb-ae99-4583-b050-e4106fe77f8b');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("d6e07074-d649-43f5-9257-1731365f8580");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('7d3aaf71-f89e-44d2-a51d-d20a4ceff81d');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("19bc42c8-00de-4ed7-a840-e6b55a9787d1");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('9d2e3430-e1e8-4621-9347-9f9b1174d766');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
When we change the models dimensions we are biologically stating that the model accumulates decisions based on different dimentions of information, such as direction and speed (for example) to make a decision. This likely closer to what biologically takes place. The model performance remains somewhat the same as in previous implementation approaches.
g) Improving Representation [2 marks]. Returning to the original implementation from section (e) (with 2 separate Ensembles), we can improve the performance by adjusting the tuning curves of the second Ensemble. Do this by setting intercepts = nengo.dists.Uniform(0.4, 0.9). This randomly chooses the x-intercepts of the neurons uniformly between 0.4 and 0.9, rather than the default of -1 to 1. Generate the same plot as in part (e).
How does this affect the performance of the model? (Try running the model a few times to see the variability in performance).
Why does the output stay at exactly zero up until the decision is made (rather than being randomly jittering around zero, as in the previous models)?
Why couldn't we use this approach in the case from part (f) where the Ensembles are combined?
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("610745d5-2134-4d0b-9482-faa60cf3fda1");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('f3d292cf-dee6-47a4-b759-6b3ff2b95135');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("a14bcb8f-7213-4474-9293-7147c49b7eae");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('52f5fa02-de92-4de4-a3c0-b978ccb61c74');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("dbaa8ea1-b120-4156-8f90-25c668d8b571");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('1b1f792d-0c19-4b69-aca3-0d808a8b79fc');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("4fc0d227-6577-4baa-9b5f-092c38793a65");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('3638b8a8-4d33-4155-afdb-86a66b6ca3c0');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
The model appears to perform much better than in (e). The output does not jitter because the the model will not begin making a decision until it has reached a certain level of confidence, the greather minimum threshold reduced the early stage jitter. We could not implement this model because have more than one ensemble and the narrower selection of intercepts in not capable of accurately repesenting the larger system.
2. Temporal Representation
In class, we discussed the Legendre Memory Unit (LMU), a method for storing input information over time. This allows us to make connections where the function being computed is a function of the input over some window in time, rather having to be a function of the current input.
In this question, we will use this to build a model that can distinguish a 1Hz sine wave from a 2Hz sine wave. Notice that it is impossible to perform this task without having information over time; if I just give you a single number at any given point in time, you can't tell whether it's from a 1Hz sine wave or a 2Hz sine wave. So we need some method to store the previous input information, and that's what the LMU does.
a) Representing Information over Time. [2 marks] The core of the LMU is to compute the differential equation ${dx \over dt} = Ax + Bu$ where $A$ and $B$ are carefully chosen using the following math:
Implement this in Nengo. Use theta=0.5 and q=6. The model should consist of a single Ensemble that is q-dimensional. Use 1000 neurons in this Ensemble. Use synapse=0.1 on both the recurrent Connection and on the input Connection.
For the input, give a 1Hz sine wave for the first 2 seconds, and a 2Hz sine wave for the second 2 seconds. This can be done with:
Run the simulation for 4 seconds. Plot x over the 4 seconds using a Probe with synapse=0.01. x should be 6-dimensional, and there should be a noticable change between its value before t=2 and after t=2.
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("1874fab7-95b2-4a87-b475-160a7b6d0e6a");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('eb58fd7c-8f33-4679-9272-c5ff5f80b11e');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
b) Computing the function. [2 marks] We now want to compute our desired function, which is "output a 1 if we have a 1Hz sine wave and a 0 if we have a 2Hz sine wave". To do this, we need to make a Connection from the LMU Ensemble out to a new Ensemble that will be our category. Have it be 1-dimensional with 50 neurons.
Normally in Nengo, when we define a Connection we specify a Python function that we want to approximate. Nengo will then choose a bunch of random x values, call the function to determine what the output should be for each one, and use that to solve for the decoders. However, in this case, we already have that set of x values! That's exactly the data you plotted in part (a). For the x values from t=0 to t=2.0 we want an output of 1. For the x values from t=2.0 to t=4.0, we want an output of -1. So, to specify these target values, we make a matrix of size (4000,1) (4000 for the 4000 time steps that you have x values for, and 1 for the output being 1-dimensional). Set the first 2000 values to 1 and the second 2000 values to -1.
Now that you have your x values and the corresponding target values, you can tell Nengo to use them when you make the Connection like this:
That will tell Nengo just to use the values you're giving it, rather than randomly sampling x and calling a function to get the target values.
Build this model and plot the resulting category (with a Probe with synapse=0.01). The output should be near 1 for the first 2 seconds, and near -1 for the second 2 seconds. (Important note: it will not be perfect at this task!)
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("ec4eb3f3-b939-46e4-88ed-115bef207ee0");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('4694684c-3e62-4503-8168-63b94568b66c');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
c) Adjusting the input. [2 marks] Repeat part b) but with an input that is a 2Hz sine wave for the first 2 seconds, and a 1Hz sine wave for the second 2 seconds (i.e. the opposite order as in part (b)). How well does this perform? Describe the similarities and differences. One particular difference you should notice is that the model may make the wrong classification for the first 0.25 seconds. Why is this happening? What could you change to fix this?
input=lambdat: np.sin(2*np.pi*t*2) ift<2elsenp.sin(2*np.pi*t)
_, _=simulate_lmu(
input=input,
compute=True,
eval_points=eval_points,
title="Decision Output $\hat{y(t)}$ from 0-4 seconds with Reversed Signal",
)
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("e13c4204-6c47-4d3e-aec1-ea467ed0efc8");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('78709cc4-f761-45df-9f35-215b1bf445e9');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
As expected, the model is incorrect for the first ~0.25 seconds. This is because the model was previouly trained with a different signal. If you were to re-train the model with the correct evaluation points you would see this incorrect classification error got to 0. You could also add a decision delay to the system so that the model would accumulate evidence before making a decision classification. This would also reduce the error. The draw-back to this approach however is that the decision classification is delayed and is not "real-time" i.e the model would be making a decision on the accumulation of previous signal data.
d) Adjusting the number of neurons. [2 marks] Repeat part b) but adjust the number of neurons in the Ensemble computing the differential equation. Try 50, 100, 200, 500, 1000, 2000, and 5000. How does the model behaviour change? Why does this happen? In addition to looking at the actual results for each run, also plot the RMSE in the classification as you adjust the number of neurons.
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("35da9720-02fe-4589-a452-7d9dc70dfee1");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('ab391baf-c5ac-423b-8e4b-c8753c91249b');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("0523d8c9-24d8-4a6e-89d8-477f0db3673d");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('746ff914-2343-40f4-8586-0aa201002419');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:01.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("bfcab011-2860-4d33-9881-39a2287b0aec");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('c8795981-251e-4700-bb63-3ca50f862924');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("e1eaabcd-ebc7-4353-99ef-d2f2a4023f66");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('4f51fe0e-f4d9-4733-ab62-4b932e0ed2b2');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("3ab59e0b-479f-43e6-9f4d-367e32182a70");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('c5a89e11-9804-4c7c-84de-9f48430a313a');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("019764b3-5502-4d99-9fe5-d18858444b83");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('01c3f5d7-e1e9-4a50-9337-42c2ffe1a991');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("932486ae-b2c7-418e-a771-61ac81e65c92");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
We can see that as we add more neurons the performance of the model improves with respect to it's accurancy. It does however, take significantly longer to run as the number of neurons increase
The above figure shows a decreasing exponential relationship between the number of neurons as the root mean squared error becuase a larger number of neurons means that we can better approximate the function we are attempting to compute.
e) Adjusting the q value. [2 marks] Repeat part b) (returning to 1000 neurons) but adjust the value of q. Try 1, 2, 4, 8, 16, 32, and 64. How does the model behaviour change? Why does this happen? In addition to looking at the actual results for each run, also plot the RMSE in the classification as you adjust the number of neurons.
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("2b393102-b2c9-481f-b65e-d2d81ee42207");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('7b27d214-e4cb-4b07-9ea0-d9a2ca86502a');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("6ba4806a-2686-4f83-986f-cd54ebb07b7f");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('79fee319-6610-48b7-8339-dbd953fd0ad4');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("37602afa-f37f-495b-a119-c1ce826d1f86");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('12b8f456-4f3a-476d-9803-a0653072d2ec');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("c7c53746-21e5-46e6-ac18-7cef38fc5900");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('fd8667a3-6c19-4ee3-ac32-566a13d88a01');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("ec94b1d1-e23c-4d3e-a6cf-4f1066014d67");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('9f5d01b2-2861-4712-9886-6f76ff061bd1');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:02.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("19ee05a2-e963-4a9a-8a25-0783e0e2a880");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('55af34b1-8e03-4d7c-8788-0686ba3c5f26');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:03.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("5c1926c5-bce1-46af-ae36-30a5e5660d99");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
Based on the findings it appears that as the dimensionality increases beyond 8, the error begins to increase. At first this seems couter-intuitive, however when we consider that there is an increase in the presense of noise with the increse in dimensionality, we can see that higher dimensions result in large amounts of noise, increasing the error. As a result, unlike the case with neurons, an increase in dimensions does not correlate to a decrease in the error.
3. Online Learning
Normally when build models with the Neural Engineering Framework, we compute the connection weights at the beginning and then leave them fixed while running the model. But, we can also apply online learning rules to adjust the connection weights over time. This has the effect of changing the function being computed. One general learning rule is the PES rule, where you provide an extra input that indicates whether the output value should be increased or decreased. This is generally called an error signal.
a) Basic online learning. [2 marks] Build a network that will learn the identity function. You will need three Ensembles, one for the input, one for the output, and one for the error. Each one is 1-dimensional and uses 200 neurons. For the input, use Nengo to randomly generate a 2Hz band-limited white noise signal as follows:
When making the learning connection, initialize it to compute the zero function and to use the PES learning rule as follows:
definitialization(x):
return0c=nengo.Connection(pre, post, function=initialization, learning_rule_type=nengo.PES(learning_rate=1e-4))
The error Ensemble should compute the difference between the output value and the desired output value. For this initial question, we want the output value to be the same as the input value (i.e. we are learning the identity function). Then connect the error Ensemble to the learning rule as follows:
nengo.Connection(error, c.learning_rule)
(Note: for this question, leave the synapse values on the Connections at their default values)
Run the model for 10 seconds and plot the input value and the resulting output value (using a Probe with synapse=0.01). The output should match the input fairly well after the first few seconds.
input_val, _, _, post_val=learn(title="PES learning for random white signal input")
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("61cc47f4-0231-4aae-a4a7-3ce542823243");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('d30a3978-d1d1-42ac-9f9c-51b6032c45af');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:03.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
b) Error calculation. [1 mark] What would happen if you reversed the sign of the error calculation (i.e. if you did target - output rather than output - target? Why does that happen?
If you subtracted the output from the target value, rather then the target from the output, you would be driving the learning in the wrong direction! That is: rather than approaching the signal as time goes infinity, the model would eventually saturate at either the maximum or minimum radius that the populations could represent, not the function that it is attempting to learn.
c) Computing metrics. [1 mark] Break your data up into 2-second chunks and compute the Root-Mean-Squared-Error between the target value (the stimulus itself) and the output from the model for each chunk. Since the simulation is 10 seconds long, you should have 5 RMSE measures (one for the first 2 seconds, one for the second 2 seconds, one for the third 2 seconds, and so on). Repeat the simulation 10 times and plot the average for each of these values. The result should show that the model gets better over time, but does not reach 0 error.
defcompute_metrics(run_time=10, attempts=10, slices=5, learning_rate=1e-4):
errors= []
for_inrange(attempts):
input_val, _, _, post_val=learn(
title="PES learning for random white signal input",
plot=False,
run_time=run_time,
learning_rate=learning_rate,
)
input=input_valoutput=post_valattempt_errors= []
assertlen(input) ==len(output)
length=len(input)
slice=int(length/slices)
start=0stop=slicefor_inrange(slices):
in_n=input[start:stop]
out_n=output[start:stop]
e=rmse(in_n, out_n)
attempt_errors.append(e)
temp=stopstart=stopstop=temp+sliceerrors.append(attempt_errors)
error_matrix=np.array(errors)
mean_errors=np.mean(error_matrix, axis=0)
tscale=np.linspace(1, slices, slices)
plt.figure()
plt.suptitle(" $\mu$ RMSE for $n$ segments of "+str(run_time) +" second signal")
plt.plot(tscale, mean_errors)
plt.xlabel("$n$")
plt.ylabel("RMSE")
plt.xlim([1, slices])
plt.show()
compute_metrics(run_time=10)
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("2b89236c-45a0-4122-bfe8-4f170ee0a3d2");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('d932bc38-6f33-4fc5-a5ae-31d32fb5b952');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:03.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
d) Increasing learning time. [2 marks] Repeat part (c), but run the model for 100 seconds instead of 10 seconds. How do the results change?
compute_metrics(run_time=100, slices=50)
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("8ae2f35e-5b69-49a2-98f7-7284a03d9153");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('455237d0-9fd8-47db-871f-23305d552311');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:22.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
We can see that as we increase the learning time, the error gets much smaller, but again does not become 0. This is because we hav a lossy system and while learning forever will decrease the RMSE, the error it will eventually approach some minimum possible value at which it will remain relatiely constant. We can also see that as the error decreases, the presense of noise becomes larger relative to the error.
e) Learning rates. [2 marks] Repeat part (d), but decrease the learning rate to 1e-5. How do the results change? How do they compare to part (c)?
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("bed4c414-e2bd-4d9b-9791-3f3bc7e20bf3");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>
<script>
(function () {
var root = document.getElementById('ac5bf04b-5798-41f0-9246-fd649dedbaa7');
var text = root.getElementsByClassName('pb-text')[0];
var fill = root.getElementsByClassName('pb-fill')[0];
text.innerHTML = 'Simulation finished in 0:00:23.';
if (100.0 > 0.) {
fill.style.transition = 'width 0.1s linear';
} else {
fill.style.transition = 'none';
}
fill.style.width = '100.0%';
fill.style.animation = 'none';
fill.style.backgroundImage = 'none'
fill.style.animation = 'none';
fill.style.backgroundImage = 'none';
})();
</script>
As we can see, decreasing the learning rate by an order of magnitude reduces the performance of the model. This doesn't come as a surprise as decreasing the learning rate does exactly what you would imagine--It decreases the rate at which the model learns. This means that after 100 seconds, the model will not have improved as much as it would have with a higher learning rate.
f) Improving performance. [1 mark] If you wanted to make the learned result even more accurate, how would you do this? What would you change about the model and learning process?
There are several options. The two most obvious methods would be to increase the learning rate so that the model learns the funciton much quicker. We could also increase the time for which the model learns. In addition to the two possible models, we could seed our model initialization wih what we might predict the function to be giving it a "head start". We could also use more insightful properties of the function to drive the error signal to zero such as the functions derivities. These would improve the overall peformace of the model.
g) Learning other functions. [1 mark] Repeat part (a), but have the system learn a function where the input is a scalar $x$, but the output is the vector $[x^2, -x]$. This will involve changing the dimensionality of some of the Ensembles and adding a function= to be computed on the Connection from the stim to the error.
_, _, _, _=learn_vectorize(title="Learned Vectorized with $x \\to [x^2,-x]$")
<script>
if (Jupyter.version.split(".")[0] < 5) {
var pb = document.getElementById("1a52cad4-9a5a-4975-a126-f282e1dcfc0d");
var text = document.createTextNode(
"HMTL progress bar requires Jupyter Notebook >= " +
"5.0 or Jupyter Lab. Alternatively, you can use " +
"TerminalProgressBar().");
pb.parentNode.insertBefore(text, pb);
}
</script>