Пример #1
0
syn_group = ngpu.CreateSynGroup \
            ("stdp", {"tau_plus":tau_plus, "tau_minus":tau_minus, \
                      "lambda":lambd, "alpha":alpha, "mu_plus":mu_plus, \
                      "mu_minus":mu_minus,  "Wmax":Wmax})

syn_dict_stdp={"weight":weight_stdp, "delay":delay, \
               "synapse_group":syn_group, "receptor":1}

ngpu.SetStatus(neuron_post, {"den_delay": den_delay})

ngpu.Connect(neuron_pre, neuron_post, conn_dict, syn_dict_stdp)

ngpu.Simulate(sim_time)

conn_id = ngpu.GetConnections(neuron_pre, neuron_post)
w = ngpu.GetStatus(conn_id, "weight")

print("Initial weight: ", weight_stdp)
print("Simulated weight: ", w[0])

Wplus = Wmax * lambd
Dt = -2.0
w1 = STDPUpdate(weight_stdp, Dt, tau_plus, tau_minus, Wplus, \
                alpha, mu_plus, mu_minus, Wmax)

print("Expected theoretical weight: ", w1)

print("dw/w: ", (w1 - w[0]) / w1)

#spike_times0=ngpu.GetRecSpikeTimes(neuron_post[0])
Пример #2
0
# connect inhibitory neurons to port 1 of all neurons
# weight Win and fixed indegree CI//2
# host 0 to host 1
ri_conn_dict = {"rule": "fixed_indegree", "indegree": CI // 2}
ri_syn_dict = inh_syn_dict
# host 0 to host 1
ngpu.RemoteConnect(0, inh_neuron, 1, neuron, ri_conn_dict, ri_syn_dict)
# host 1 to host 0
ngpu.RemoteConnect(1, inh_neuron, 0, neuron, ri_conn_dict, ri_syn_dict)

ngpu.Simulate()

data_list = ngpu.GetRecordData(record)

for i in range(500):
    conn_id = ngpu.GetConnections(i + 1)
    n_out_conn = len(conn_id)
    if (n_out_conn != NE + NI):
        print("Expected number of out connections per neuron: ", NE + NI)
        print("Number of out connections of neuron ", i + 1, ": ", \
              n_out_conn)
        sys.exit(1)

for i in range(10):
    i_target = randrange(n_neurons)
    conn_id = ngpu.GetConnections(target=i_target + 1)
    n_in_conn = len(conn_id)
    if (n_in_conn != 2 * (NE + NI) + 1):
        print("Expected number of in connections per neuron: ",
              2 * (NE + NI) + 1)
        print("Number of in connections of neuron ", i_target, ": ", \
Пример #3
0
        delay_pre = 0.1 + round(Dt_max * i / N, 1)
        syn_dict_stdp={"weight":weight_stdp, "delay":delay_pre, \
                       "synapse_group":syn_group, "receptor":1}

        ngpu.Connect([neuron_pre[i]], [neuron_post[j]], conn_dict,
                     syn_dict_stdp)

ngpu.Simulate(sim_time)

Wplus = Wmax * lambd
max_dw_rel = 0
mse = 0
count = 0
for j in range(N):
    for i in range(N):
        conn_id = ngpu.GetConnections(neuron_pre[i], neuron_post[j])
        w = ngpu.GetStatus(conn_id, "weight")
        # print("Initial weight: ", weight_stdp)
        # print("Simulated weight: ", w[0])
        delay_pre = 0.1 + round(Dt_max * i / N, 1)
        delay_post = 0.1 + round(Dt_max * j / N, 1)
        Dt = Dt_offset + delay_post - delay_pre
        if Dt >= 0:
            Dt1 = -(Dt_spike - Dt)
        else:
            Dt1 = Dt_spike + Dt
        if (Dt > 1.0e-6) | (Dt < -1.0e-6):
            w1 = weight_stdp
            for ispike in range(n_spikes):
                w1 = STDPUpdate(w1, Dt, tau_plus, tau_minus, Wplus, \
                                alpha, mu_plus, mu_minus, Wmax)
Пример #4
0
conn_dict = {"rule": "all_to_all"}
even_to_odd_syn_dict = {
    "weight_array": even_to_odd_weight,
    "delay_array": even_to_odd_delay
}

odd_to_even_syn_dict = {
    "weight_array": odd_to_even_weight,
    "delay_array": odd_to_even_delay
}

ngpu.Connect(neuron_even, neuron_odd, conn_dict, even_to_odd_syn_dict)
ngpu.Connect(neuron_odd, neuron_even, conn_dict, odd_to_even_syn_dict)

# Even to all
conn_id = ngpu.GetConnections(neuron_even, neuron)
conn_status_dict = ngpu.GetStatus(conn_id)
print("########################################")
print("Even to all")
for i in range(len(conn_status_dict)):
    print(conn_status_dict[i])
print()
print()

# Even to all weight, delay
conn_status_dict = ngpu.GetStatus(conn_id, ["weight", "delay"])
print("########################################")
print("Even to all weight, delat")
for i in range(len(conn_status_dict)):
    print(conn_status_dict[i])
print()
Пример #5
0
syn_dict_stdp={"weight":weight_stdp, "delay_array":delay_stdp_list, \
               "synapse_group":syn_group}

ngpu.Connect(neuron0, neuron1, conn_dict_full, syn_dict_stdp)

ngpu.Simulate(1000.0)

#conn_id = ngpu.GetConnections(neuron0, neuron1)
dt = dt_list
#w = ngpu.GetStatus(conn_id, "weight")

expect_w = []
dw = []
sim_w = []
for i in range(N):
    conn_id = ngpu.GetConnections(neuron0, neuron1[i])
    w = ngpu.GetStatus(conn_id, "weight")
    w1 = STDPUpdate(weight_stdp, dt[i], tau_plus, tau_minus, lambd*Wmax, \
                    alpha, mu_plus, mu_minus, Wmax)
    expect_w.append(w1)
    sim_w.append(w[0])
    dw.append(w1 - w[0])
    if abs(dw[i]) > tolerance:
        print("Expected weight: ", w1, " simulated: ", w)
        #sys.exit(1)

#sys.exit(0)

import matplotlib.pyplot as plt

plt.figure(1)
Пример #6
0
for i in range(n_test - 2):
    i_neuron_list.append(neuron[randrange(n_neurons)])
    i_receptor_list.append(0)
    var_name_list.append("spike")

# create multimeter record of spikes
record = ngpu.CreateRecord("", var_name_list, i_neuron_list, i_receptor_list)

ngpu.Simulate()

data_list = ngpu.GetRecordData(record)

n_conn_tot = 0
for i in range(1000):
    conn_id = ngpu.GetConnections(i + 1)
    n_out_conn = len(conn_id)
    n_conn_tot = n_conn_tot + n_out_conn

if (n_conn_tot != (NE + NI) * CPN):
    print("Expected total number of connections: ", (NE + NI) * CPN)
    print("Total number of connections ", n_conn_tot)
    sys.exit(1)

row_sum = list(data_list[0])
for row in data_list[1:len(data_list)]:
    for i in range(len(row_sum)):
        row_sum[i] = row_sum[i] + row[i]

spike = row_sum[1:len(row_sum)]
spike_arr = np.array(spike)