StaticPulseDendriticDelay is not working #611
-
The delay kernel provided to StaticPulseDendriticDelay has no effect. Example: #! /usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
from pygenn import genn_model
from pygenn.genn_model import GeNNModel, create_custom_neuron_class
from pygenn.genn_wrapper import NO_DELAY
model_input_spike = create_custom_neuron_class(
"inp_neur",
param_names=["rate"],
var_name_types=[("t_spk", "scalar")],
sim_code="""
""",
threshold_condition_code="$(t) - $(t_spk) >= 1.0/$(rate)",
reset_code="$(t_spk) = $(t);",
is_auto_refractory_required=False)
model_output_li = create_custom_neuron_class(
"output_neur",
param_names=["tau"],
var_name_types=[("v", "scalar")],
sim_code="""
$(v) += DT * ($(Isyn) - $(v));
"""
)
DT = 0.1
# just to get some different levels of inhibition
KERNEL_G = -np.array([.0, .2, .2, .2, .0,
.2, .5, .5, .5, .2,
.2, .5, 1., .5, .2,
.2, .5, .5, .5, .2,
.0, .2, .2, .2, .0])
T_DELAY = 1.5
N_DELAY_STEPS = int(T_DELAY / DT)
KERNDEL_D = np.ones((25)).astype("int") * N_DELAY_STEPS
syn_vars = {
"g": KERNEL_G,
"d": KERNDEL_D
}
kernel_params = {
"conv_kh": 5,
"conv_kw": 5,
"conv_ih": 1,
"conv_iw": 1,
"conv_ic": 1,
"conv_oh": 5,
"conv_ow": 5,
"conv_oc": 1
}
kernel_conn = genn_model.init_toeplitz_connectivity("Conv2D", kernel_params)
model = GeNNModel("float", "test")
model.dT = DT
P = model.add_neuron_population("input", 1, model_input_spike,
{"rate": 1.0}, {"t_spk": 0.0})
S = model.add_neuron_population("output", 25, model_output_li,
{"tau": 1.0}, {"v": 0.0})
syn_SP_E = model.add_synapse_population("exc", "DENSE_GLOBALG", NO_DELAY,
P, S, "StaticPulse",
{}, {"g": 1.0},
{}, {}, "DeltaCurr",
{}, {})
syn_SP_I = model.add_synapse_population("inh", "TOEPLITZ_KERNELG", NO_DELAY,
P, S, "StaticPulseDendriticDelay", {}, syn_vars,
{}, {}, "DeltaCurr", {}, {}, kernel_conn)
P.spike_recording_enabled = True
T = 10.0
NT = int(T/model.dT)
T = NT * model.dT
model.build()
model.load(num_recording_timesteps=NT)
t_ax = np.linspace(0., T, NT, endpoint=False)
sv_rec = np.ndarray((NT, 25))
for t in range(NT):
model.step_time()
S.pull_var_from_device("v")
sv_rec[t,:] = S.vars["v"].view
model.pull_recording_buffers_from_device()
sp_t, _ = P.spike_recording_data
plt.plot(t_ax, sv_rec)
plt.vlines(sp_t, sv_rec.min(), sv_rec.max(), linestyles='--', label="input spikes")
plt.xlabel("t")
plt.ylabel("Output Population V")
plt.legend()
plt.show() Here, inhibition should be delayed, but arrives at the exact same time as the excitation. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You need to set the maximum number of dendritic delay slots with something like: syn_SP_I.pop.set_max_dendritic_delay_timesteps(N_DELAY_STEPS) |
Beta Was this translation helpful? Give feedback.
-
This still results in the same model output |
Beta Was this translation helpful? Give feedback.
-
Fixed: |
Beta Was this translation helpful? Give feedback.
Fixed:
syn_SP_I.pop.set_max_dendritic_delay_timesteps(N_DELAY_STEPS + 1)
maximum number of delay steps have to be 1 larger than the largest number of steps in the kernel.