Ejemplo n.º 1
0
}  # prob. for K channel activation

s_ini = {"g": -0.2}

ps_p = {
    "tau": 1.0,  # Decay time constant [ms] 
    "E": -80.0
}  # Reversal potential [mV]

stim_ini = {"startSpike": [0], "endSpike": [1]}

pop1 = model.add_neuron_population("Pop1", 10, "TraubMiles", p, ini)
stim = model.add_neuron_population("Stim", 1, "SpikeSourceArray", {}, stim_ini)

model.add_synapse_population("Pop1self", "SPARSE_GLOBALG", 10, pop1, pop1,
                             "StaticPulse", {}, s_ini, {}, {}, "ExpCond", ps_p,
                             {}, init_connectivity(ring_model, {}))

model.add_synapse_population("StimPop1", "SPARSE_GLOBALG", NO_DELAY, stim,
                             pop1, "StaticPulse", {}, s_ini, {}, {}, "ExpCond",
                             ps_p, {}, init_connectivity("OneToOne", {}))
stim.set_extra_global_param("spikeTimes", [0.0])

model.build()
model.load()

v = np.empty((2000, 10))
v_view = pop1.vars["V"].view
while model.t < 200.0:
    model.step_time()
Ejemplo n.º 2
0
                                if_params, if_init)
]

# Create current source to deliver input to first layers of neurons
current_input = model.add_current_source("current_input", cs_model, "neuron0",
                                         {}, {"magnitude": 0.0})

# Create subsequent neuron layer
for i, w in enumerate(weights):
    neuron_layers.append(
        model.add_neuron_population("neuron%u" % (i + 1), w.shape[1],
                                    "RulkovMap", rm_params, rm_init))

# Create synaptic connections between layers
model.add_synapse_population("synapse%u" % 0, "DENSE_INDIVIDUALG", NO_DELAY,
                             neuron_layers[0], neuron_layers[1], "StaticPulse",
                             {}, {"g": weights[0].flatten()}, {}, {},
                             "DeltaCurr", {}, {})
model.add_synapse_population(
    "synapse%u" % 1, "DENSE_INDIVIDUALG", DELAY, neuron_layers[1],
    neuron_layers[2], stdp, {G_MAX, G_MIN},
    {"g": init_var("Uniform", INIT_WEIGHTS)}, {}, {}, cb_synapse, ex_params,
    {"V": 50.0}, init_connectivity("FixedProbabilityNoAutapse", fixed_prob))
model.add_synapse_population(
    "synapse%u" % 2, "DENSE_INDIVIDUALG", DELAY, neuron_layers[2],
    neuron_layers[2], "StaticPulse", {},
    {"g": init_var(lateral_inhibition, {"g": 0.025})}, {}, {}, "DeltaCurr", {},
    init_connectivity("FixedProbabilityNoAutapse", fixed_prob))

# Build and load our model
model.build()
model.load()
Ejemplo n.º 3
0
for k in neurons_count.keys():
    if k == "out":
        neuron_layers[k] = model.add_neuron_population(k, neurons_count[k],
                                                       if_model, IF_PARAMS,
                                                       if_init)
    else:
        neuron_layers[k] = model.add_neuron_population(k, neurons_count[k],
                                                       poisson_model, {},
                                                       poisson_init)

inp2out_w = np.load("fusi_new6.npy")

inp2out = model.add_synapse_population("inp2out", "DENSE_INDIVIDUALG",
                                       NO_DELAY, neuron_layers['inp'],
                                       neuron_layers['out'], "StaticPulse", {},
                                       {"g": inp2out_w.flatten()}, {}, {},
                                       "DeltaCurr", {}, {})

inh2out = model.add_synapse_population("inh2out", "DENSE_INDIVIDUALG",
                                       NO_DELAY, neuron_layers['inh'],
                                       neuron_layers['out'], "StaticPulse", {},
                                       {"g": -0.035}, {}, {}, "DeltaCurr", {},
                                       {})

# Build and load our model
model.build()
model.load()

# ----------------------------------------------------------------------------
# Training
Ejemplo n.º 4
0
# Create neuron populations
lif_init = {"V": -60.0, "RefracTime": 0.0}
pn = model.add_neuron_population("pn", NUM_PN, "LIF", PN_PARAMS, lif_init)
kc = model.add_neuron_population("kc", NUM_KC, "LIF", KC_PARAMS, lif_init)
ggn = model.add_neuron_population("ggn", 1, "LIF", GGN_PARAMS, lif_init)
mbon = model.add_neuron_population("mbon", NUM_MBON, "LIF", MBON_PARAMS,
                                   lif_init)

# Create current source to deliver input to network
pn_input = model.add_current_source("pn_input", cs_model, "pn", {},
                                    {"magnitude": 0.0})

# Create synapse populations
model.add_synapse_population(
    "pn_kc", "SPARSE_GLOBALG", NO_DELAY, pn, kc, "StaticPulse", {},
    {"g": PN_KC_WEIGHT}, {}, {}, "ExpCurr", {"tau": PN_KC_TAU_SYN}, {},
    init_connectivity("FixedProbabilityNoAutapse", {"prob": PN_KC_SPARSITY}))

model.add_synapse_population("kc_ggn", "DENSE_GLOBALG", NO_DELAY, kc, ggn,
                             "StaticPulse", {}, {"g": KC_GGN_WEIGHT}, {}, {},
                             "ExpCurr", {"tau": KC_GGN_TAU_SYN}, {})

model.add_synapse_population("ggn_kc", "DENSE_GLOBALG", NO_DELAY, ggn, kc,
                             graded_synapse_model, GGN_KC_PARAMS,
                             {"g": GGN_KC_WEIGHT}, {}, {}, "ExpCurr",
                             {"tau": GGN_KC_TAU_SYN}, {})

kc_mbon = model.add_synapse_population(
    "kc_mbon", "DENSE_INDIVIDUALG", NO_DELAY, kc, mbon, symmetric_stdp,
    KC_MBON_PARAMS, {"g": init_var("Uniform", KC_MBON_WEIGHT)}, {}, {},
    "ExpCurr", {"tau": KC_MBON_TAU_SYN}, {})
Ejemplo n.º 5
0
neuron_layers = {}

for k in neurons_count.keys():
    if k == "out":
        neuron_layers[k] = model.add_neuron_population(k, neurons_count[k],
                                                       if_model, IF_PARAMS,
                                                       if_init)
    else:
        neuron_layers[k] = model.add_neuron_population(k, neurons_count[k],
                                                       poisson_model, {},
                                                       poisson_init)

# fully connected input to output
inp2out = model.add_synapse_population("inp2out", "DENSE_INDIVIDUALG",
                                       NO_DELAY, neuron_layers['inp'],
                                       neuron_layers['out'], fusi_model,
                                       FUSI_PARAMS, fusi_init, {},
                                       fusi_post_init, "DeltaCurr", {}, {})
# inp2out = model.add_synapse_population(
#     "inp2out", "DENSE_INDIVIDUALG", NO_DELAY,
#     neuron_layers['inp'], neuron_layers['out'],
#     "StaticPulse", {}, {"g": g_init.flatten()}, {}, {},
#     "DeltaCurr", {}, {})

# fully connected inhibitory to output
inh2out = model.add_synapse_population("inh2out", "DENSE_INDIVIDUALG",
                                       NO_DELAY, neuron_layers['inh'],
                                       neuron_layers['out'], "StaticPulse", {},
                                       {"g": INH_WT}, {}, {}, "DeltaCurr", {},
                                       {})
Ejemplo n.º 6
0
neuron_layers = {}

for k in neurons_count.keys():
    if k == "out":
        neuron_layers[k] = model.add_neuron_population(k, neurons_count[k],
                                                       if_model, IF_PARAMS,
                                                       if_init)
    else:
        neuron_layers[k] = model.add_neuron_population(k, neurons_count[k],
                                                       poisson_model, {},
                                                       poisson_init)

# fully connected input to output
inp2out = model.add_synapse_population("inp2out", "DENSE_INDIVIDUALG",
                                       NO_DELAY, neuron_layers['inp'],
                                       neuron_layers['out'], fusi_model,
                                       FUSI_PARAMS, fusi_init, {},
                                       fusi_post_init, "DeltaCurr", {}, {})

# fully connected inhibitory to output
inh2out = model.add_synapse_population("inh2out", "DENSE_INDIVIDUALG",
                                       NO_DELAY, neuron_layers['inh'],
                                       neuron_layers['out'], "StaticPulse", {},
                                       {"g": -0.035}, {}, {}, "DeltaCurr", {},
                                       {})

# teacher2out_mat = np.zeros((neurons_count["out"], neurons_count["teacher"]))
# teacher2out_mat = np.full((neurons_count["out"], neurons_count["teacher"]), TEACHER_UNSTIM_STRENGTH)
# fill_idx = [(i*TEACHER_NUM, (i+1)*TEACHER_NUM) for i in range(NUM_CLASSES)]
# counter = 0
# for i in range(teacher2out_mat.shape[0]):
neuron_layers = [
    model.add_neuron_population("neuron0", weights[0].shape[0], if_model,
                                IF_PARAMS, if_init)
]

# Create subsequent neuron layer
for i, w in enumerate(weights):
    neuron_layers.append(
        model.add_neuron_population("neuron%u" % (i + 1), w.shape[1], if_model,
                                    IF_PARAMS, if_init))

# Create synaptic connections between layers
for i, (pre, post,
        w) in enumerate(zip(neuron_layers[:-1], neuron_layers[1:], weights)):
    model.add_synapse_population("synapse%u" % i, "DENSE_INDIVIDUALG",
                                 NO_DELAY, pre, post, "StaticPulse", {},
                                 {"g": w.flatten()}, {}, {}, "DeltaCurr", {},
                                 {})

# Create current source to deliver input to first layers of neurons
current_input = model.add_current_source("current_input", cs_model, "neuron0",
                                         {}, {"magnitude": 0.0})

# Build and load our model
model.build()
model.load()

# ----------------------------------------------------------------------------
# Simulate
# ----------------------------------------------------------------------------
# Load testing data
testing_images = np.load("testing_images.npy")
Ejemplo n.º 8
0
extra_poisson_params = {"rate" : 100.0}
poisson_init = {"timeStepToSpike" : 0.0}

model = GeNNModel("float", "fusi")
model.dT = TIMESTEP

presyn = model.add_neuron_population("presyn", 1, "PoissonNew", presyn_params, poisson_init)
postsyn = model.add_neuron_population("postsyn", 1, if_model, if_params, if_init)
extra_poisson = model.add_neuron_population("extra_poisson", 10, "PoissonNew",
                                            extra_poisson_params, poisson_init)



pre2post = model.add_synapse_population(
            "pre2post", "DENSE_INDIVIDUALG", NO_DELAY,
            presyn, postsyn,
            fusi_model, fusi_params, fusi_init, {}, fusi_post_init,
            "DeltaCurr", {}, {})

extra_poisson2post = model.add_synapse_population(
            "extra_poisson2post", "DENSE_GLOBALG", NO_DELAY,
            extra_poisson, postsyn,
            "StaticPulse", {}, {"g": POSTSYN_WT}, {}, {},
            "DeltaCurr", {}, {})

model.build()
model.load()

pre_spikes = []
post_spikes = []
post_v = []
Ejemplo n.º 9
0
#             "synapse%u" % i, "DENSE_INDIVIDUALG", NO_DELAY,
#             pre, post,
#             "StaticPulse", {}, {"g": weights_0_1.flatten()}, {}, {},
#             "DeltaCurr", {}, {}))
#     else:
#         synapses.append(model.add_synapse_population(
#             "synapse%u" % i, "DENSE_INDIVIDUALG", NO_DELAY,
#             pre, post,
#             stdp_model, STDP_PARAMS, stdp_init, {}, {},
#             "DeltaCurr", {}, {}))

for i, (pre, post) in enumerate(zip(neuron_layers[:-1], neuron_layers[1:])):
    if i == 0:
        synapses.append(
            model.add_synapse_population("synapse%u" % i, "DENSE_INDIVIDUALG",
                                         NO_DELAY, pre, post, "StaticPulse",
                                         {}, stdp_init, {}, {}, "DeltaCurr",
                                         {}, {}))
    else:
        synapses.append(
            model.add_synapse_population("synapse%u" % i, "DENSE_INDIVIDUALG",
                                         NO_DELAY, pre, post, stdp_model,
                                         STDP_PARAMS, stdp_init, {}, {},
                                         "DeltaCurr", {}, {}))

# Create current source to deliver input to first layers of neurons
current_input = model.add_current_source("current_input", cs_model, "neuron0",
                                         {}, {"magnitude": 0.0})

# Create current source to deliver target output to last layer of neurons
current_output = model.add_current_source("current_output", cs_model,
                                          "neuron2", {}, {"magnitude": 0.0})
Ejemplo n.º 10
0
            "Ioffset": 0.0,
            "TauRefrac": 0.1,
        }
        lif_vars = {"V": 0.0 * ones, "RefracTime": 0.0 * ones}
        layer = model.add_neuron_population(f"LIF{i}", parameters.features,
                                            "LIF", lif_params, lif_vars)
        layers.append(layer)
        # From https://github.com/genn-team/genn/blob/master/userproject/PoissonIzh_project/model/PoissonIzh.cc#L93
        model.add_synapse_population(
            f"PL{i}",
            "DENSE_INDIVIDUALG",
            NO_DELAY,
            f"PoissonNew{i}",
            f"LIF{i}",
            "StaticPulse",
            {},
            {"g": weights},
            {},
            {},
            "DeltaCurr",
            {},
            {},
        )

    model.build()
    model.load()

    # Run simulation
    start = time.time()
    layer_spikes = []
    for _ in range(parameters.sequence_length):
Ejemplo n.º 11
0
                                IF_PARAMS, if_init)
]

# Create subsequent neuron layer
for i, w in enumerate(weights):
    neuron_layers.append(
        model.add_neuron_population("neuron%u" % (i + 1), w.shape[1], if_model,
                                    IF_PARAMS, if_init))

# Create synaptic connections between layers
for i, (pre, post,
        w) in enumerate(zip(neuron_layers[:-1], neuron_layers[1:], weights)):
    if i == 0:
        {
            model.add_synapse_population("synapse%u" % i, "DENSE_INDIVIDUALG",
                                         NO_DELAY, pre, post, "StaticPulse",
                                         {}, {"g": w.flatten()}, {}, {},
                                         "DeltaCurr", {}, {})
        }
    else:
        {
            model.add_synapse_population("synapse%u" % i, "DENSE_INDIVIDUALG",
                                         NO_DELAY, pre, post,
                                         stdp_multiplicative, stdp_params,
                                         stdp_init, stdp_pre_init,
                                         stdp_post_init, "ExpCurr",
                                         post_syn_params, {})
        }

# Create current source to deliver input to first layers of neurons
current_input = model.add_current_source("current_input", cs_model, "neuron0",
                                         {}, {"magnitude": 0.0})