Ejemplo n.º 1
0
# Create model
model = GeNNModel("float", "mnist_mb")
model.dT = DT
model._model.set_seed(1337)

# 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}, {})
Ejemplo n.º 2
0
        break

# weights[1] = np.random.uniform(G_MAX/2, G_MAX, (128,10))

# Initial values to initialise all neurons to
if_init = {"V": 0.0, "SpikeCount": 0}
rm_init = {"V": 50.0, "preV": 50.0}

# Create first neuron layer
neuron_layers = [
    model.add_neuron_population("neuron0", weights[0].shape[0], if_model,
                                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},
Ejemplo n.º 3
0
model.dT = 0.1

# Initialise IzhikevichVariable parameters - arrays will be automatically uploaded
izk_init = {
    "V": -65.0,
    "U": -20.0,
    "a": [0.02, 0.1, 0.02, 0.02],
    "b": [0.2, 0.2, 0.2, 0.2],
    "c": [-65.0, -65.0, -50.0, -55.0],
    "d": [8.0, 2.0, 2.0, 4.0]
}

# Add neuron populations and current source to model
pop = model.add_neuron_population("Neurons", 4, "IzhikevichVariable", {},
                                  izk_init)
model.add_current_source("CurrentSource", "DC", "Neurons", {"amp": 10.0}, {})

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

# Create a numpy view to efficiently access the membrane voltage from Python
voltage_view = pop.vars["V"].view

# Simulate
v = None
while model.t < 200.0:
    model.step_time()
    model.pull_state_from_device("Neurons")
    v = np.copy(voltage_view) if v is None else np.vstack((v, voltage_view))