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
The leaky integrate-and-fire (LIF) cell component in ngc-learn is a stepping stone towards working with more biophysical intricate cell components when crafting your neuronal circuit models. This [cell](ngclearn.components.neurons.spiking.LIFCell) is markedly different from the [simplified LIF](ngclearn.components.neurons.spiking.sLIFCell) in both its implemented dynamics as well as what modeling routines that it offers, including the fact that it does not offer implicit fixed lateral inhibition like the `SLIF` does (one would need to explicitly model the lateral inhibition as a separate population of `LIF` cells, as we do in the [Diehl and Cook model museum spiking network](../../museum/snn_dc.md)). Furthermore, using this neuronal cell is a useful transition to using the more complicated and biophysically more accurate neuronal models such as the [adaptive exponential integrator cell](ngclearn.components.neurons.spiking.adExCell) or the [Izhikevich cell](ngclearn.components.neurons.spiking.izhikevichCell).
18
4
19
5
## Instantiating the LIF Neuronal Cell
20
6
21
-
To implement a single-component dynamical system made up of a single LIF
22
-
cell, you would write code akin to the following:
7
+
To implement a single-component dynamical system made up of a single LIF cell, you would write code akin to the following:
23
8
24
9
```python
25
10
from jax import numpy as jnp, random, jit
26
11
27
-
from ngcsimlib.context import Context
28
-
from ngclearn.utils import JaxProcess
12
+
from ngclearn import Context, MethodProcess
29
13
## import model-specific mechanisms
30
14
from ngclearn.components.neurons.spiking.LIFCell import LIFCell
31
15
from ngclearn.utils.viz.spike_plot import plot_spiking_neuron
## Simulating the LIF on Stepped Constant Electrical Current
66
48
67
-
Given our single-LIF dynamical system above, let us write some code to use
68
-
our `LIF` node and visualize the resultant spiking pattern super-imposed
69
-
over its membrane (voltage) potential by feeding
70
-
into it a step current, where the electrical current `j` starts at $0$ then
71
-
switches to $0.3$ at $t = 10$ ms (much as we did for the `SLIF` component
72
-
in the previous lesson). We craft the simulation portion of our code like so:
73
-
49
+
Given our single-LIF dynamical system above, let us write some code to use our `LIF` node and visualize the resultant spiking pattern super-imposed over its membrane (voltage) potential by feeding into it a step current, where the electrical current `j` starts at $0$ then switches to $0.3$ at $t = 10$ ms (much as we did for the `SLIF` component in the previous lesson). We craft the simulation portion of our code like so:
74
50
75
51
```python
76
52
# create a synthetic electrical step current
@@ -80,58 +56,39 @@ curr_in = []
80
56
mem_rec = []
81
57
spk_rec = []
82
58
83
-
model.reset()
59
+
reset_process.run()
84
60
for ts inrange(current.shape[1]):
85
61
j_t = jnp.expand_dims(current[0,ts], axis=0) ## get data at time ts
86
-
model.clamp(j_t)
87
-
model.advance(t=ts*1., dt=dt)
62
+
clamp(j_t)
63
+
advance_process.run(t=ts*1., dt=dt)
88
64
## naively extract simple statistics at time ts and print them to I/O
89
-
v = cell.v.value
90
-
s = cell.s.value
65
+
v = cell.v.get()
66
+
s = cell.s.get()
91
67
curr_in.append(j_t)
92
68
mem_rec.append(v)
93
69
spk_rec.append(s)
94
70
print("\r{}: s {} ; v {}".format(ts, s, v), end="")
95
71
print()
96
72
```
97
73
98
-
Then, we can plot the input current, the neuron's voltage `v`, and its output
99
-
spikes as follows:
74
+
Then, we can plot the input current, the neuron's voltage `v`, and its output spikes as follows:
As we might observe, the LIF operates very differently from the SLIF, notably
115
-
that its dynamics live in the different space of values (one aspect of the
116
-
SLIF is that its dynamics are effectively normalized/configured to live
117
-
a non-negative membrane potential number space), specifically values that
118
-
are a bit better aligned with those observed in experimental neuroscience.
119
-
While more biophysically more accurate, the `LIF` typically involves consideration
120
-
of multiple additional hyper-parameters/simulation coefficients, including
121
-
the resting membrane potential value `v_rest` and the reset membrane value
122
-
`v_reset` (upon occurrence of a spike/emitted action potential); the `SLIF`,
123
-
in contrast, assumed a `v_reset = v_reset = 0.`. Note that the `LIF`'s
124
-
`tau_theta` and `theta_plus` coefficients govern its particular adaptive threshold,
125
-
which is a particular increment variable (one per cell in the `LIF` component)
126
-
that gets adjusted according to its own dynamics and added to the fixed constant
127
-
threshold `thr`, i.e., the threshold that a cell's membrane potential must
128
-
exceed for a spike to be emitted.
129
-
130
-
The `LIF` cell component is particularly useful when more flexibility is required/
131
-
desired in setting up neuronal dynamics, particularly when attempting to match
132
-
various mathematical models that have been proposed in computational neuroscience.
133
-
This benefit comes at the greater cost of additional tuning and experimental planning,
134
-
whereas the `SLIF` can be a useful go-to initial spiking cell for building certain spiking
135
-
models such as those proposed in machine intelligence research (we demonstrate
136
-
one such use-case in the context of the
137
-
[feedback alignment-trained spiking network](../../museum/snn_bfa.md) that we offer in the model museum).
91
+
As we might observe, the LIF operates very differently from the SLIF, notably that its dynamics live in the different space of values (one aspect of the SLIF is that its dynamics are effectively normalized/configured to live a non-negative membrane potential number space), specifically values that are a bit better aligned with those observed in experimental neuroscience. While more biophysically more accurate, the `LIF` typically involves consideration of multiple additional hyper-parameters/simulation coefficients, including
92
+
the resting membrane potential value `v_rest` and the reset membrane value `v_reset` (upon occurrence of a spike/emitted action potential); the `SLIF`, in contrast, assumed a `v_reset = v_reset = 0.`. Note that the `LIF`'s `tau_theta` and `theta_plus` coefficients govern its particular adaptive threshold, which is a particular increment variable (one per cell in the `LIF` component) that gets adjusted according to its own dynamics and added to the fixed constant threshold `thr`, i.e., the threshold that a cell's membrane potential must exceed for a spike to be emitted.
93
+
94
+
The `LIF` cell component is particularly useful when more flexibility is required/desired in setting up neuronal dynamics, particularly when attempting to match various mathematical models that have been proposed in computational neuroscience. This benefit comes at the greater cost of additional tuning and experimental planning, whereas the `SLIF` can be a useful go-to initial spiking cell for building certain spiking models such as those proposed in machine intelligence research (we demonstrate one such use-case in the context of the [feedback alignment-trained spiking network](../../museum/snn_bfa.md) that we offer in the model museum).
0 commit comments