import numpy as np
import pynn_genn as sim
import copy
from pynn_genn.random import NativeRNG, NumpyRNG, RandomDistribution

np_rng = NumpyRNG(seed=1)
rng = NativeRNG(np_rng, seed=1)

timestep = 1.
sim.setup(timestep)

n_neurons = 100
params = copy.copy(sim.IF_curr_exp.default_parameters)
pre = sim.Population(n_neurons, sim.SpikeSourceArray,
                     {'spike_times': [[1] for _ in range(n_neurons)]},
                     label='pre')
params['tau_syn_E'] = 5.
post = sim.Population(n_neurons, sim.IF_curr_exp, params,
                      label='post')
post.record('spikes')

dist_params = {'low': 0.0, 'high': 10.0}
dist = 'uniform'
rand_dist = RandomDistribution(dist, rng=rng, **dist_params)
var = 'weight'
on_device_init = bool(1)
conn = sim.AllToAllConnector()
syn = sim.StaticSynapse(weight=5./n_neurons, delay=1)#rand_dist)
proj = sim.Projection(pre, post, conn, synapse_type=syn, use_procedural=bool(0))

sim.run(2 * n_neurons)
Exemplo n.º 2
0
import numpy as np
import pynn_genn as sim
import copy
from pynn_genn.random import NativeRNG, NumpyRNG, RandomDistribution

np_rng = NumpyRNG()
rng = NativeRNG(np_rng)

timestep = 1.
sim.setup(timestep)

n_pre = 10000
n_post = 10000
params = copy.copy(sim.IF_curr_exp.default_parameters)
pre = sim.Population(n_pre, sim.IF_curr_exp, params, label='pre')
post = sim.Population(n_post, sim.IF_curr_exp, params, label='post')

dist_params = {'low': 0.0, 'high': 10.0}
dist = 'uniform'
rand_dist = RandomDistribution(dist, rng=rng, **dist_params)
var = 'weight'
on_device_init = bool(1)
p_conn = 0.3
n = 30  #int(n_post * p_conn)
conn = sim.FixedNumberPostConnector(n, rng=rng, with_replacement=True)
syn = sim.StaticSynapse(weight=rand_dist, delay=1)  #rand_dist)
proj = sim.Projection(pre, post, conn, synapse_type=syn)

sim.run(10)

comp_var = np.asarray(proj.getWeights(format='array'))
Exemplo n.º 3
0
BACKEND = 'SingleThreadedCPU' if bool(0) else 'CUDA'

INF = float(10e10)

#SEED = 7
SEED = None
RNG = np.random.RandomState(seed=SEED)


USE_GABOR_LAYER = bool(0)

SIM_NAME = GENN

if SIM_NAME == GENN:
    from pynn_genn.random import NativeRNG, NumpyRNG
    NP_RNG = NumpyRNG(seed=SEED)
    NATIVE_RNG = NativeRNG(NP_RNG, seed=SEED)

else:
    NP_RNG = RNG
    NATIVE_RNG = RNG


GPU_ID = 0
USE_PROCEDURAL = bool(0)

TIMESTEP = 0.10 #ms
SAMPLE_DT = 50.0 #ms
SAMPLE_OFFSET = 10. # ms
SAMPLE_MAX_T = SAMPLE_OFFSET + 5. # ms
# iw = 28