예제 #1
0
type2 = -1  # OFF-type neuron

a = 1.0/0.015
c = 1.0/3.0
h_list = [[0,0],[0,0]]
h_list[0][0] = lambda t : 0
h_list[0][1] = lambda t : -c*np.exp(-a*t)*((a*t)**5/120.0-(a*t)**7/5040.0)*(t>=0)
h_list[1][0] = lambda t : c*np.exp(-a*t)*((a*t)**5/120.0-(a*t)**7/5040.0)*(t>=0)
h_list[1][1] = lambda t : 0

fig_title = 'Signal Encoded Using Coupled IAF Encoder'
print fig_title
s_list = func_timer(iaf.iaf_encode_coupled)(u, dt, [b1, b2], [d1, d2],
                                               [k1, k2], h_list, [type1, type2])
output_count += 1
pl.plot_encoded(t, u, s_list[0], fig_title + ' #1',
                output_name + str(output_count) + output_ext)
output_count += 1
pl.plot_encoded(t, u, s_list[1], fig_title + ' #2',
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Coupled IAF Decoder'
print fig_title
u_rec = func_timer(iaf.iaf_decode_coupled)(s_list, dur, dt, 
                                              [b1, b2], [d1, d2], [k1, k2],
                                              h_list)
pl.plot_compare(t, u, u_rec, fig_title,
                output_name + str(output_count) + output_ext)


예제 #2
0
b1 = 3.5   # bias
d1 = 0.7   # threshold
R1 = 10.0  # resistance
C1 = 0.01  # capacitance

b2 = 3.4   # bias
d2 = 0.8   # threshold
R2 = 9.0   # resistance
C2 = 0.01  # capacitance

output_count += 1
fig_title = 'Signal Encoded Using Leaky IAF Encoder #1'
print fig_title
s1 = func_timer(iaf.iaf_encode)(u, dt, b1, d1, R1, C1)
pl.plot_encoded(t, u, s1, fig_title,
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Encoded Using Leaky IAF Encoder #2'
print fig_title
s2 = func_timer(iaf.iaf_encode)(u, dt, b2, d2, R2, C2)
pl.plot_encoded(t, u, s2, fig_title,
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Leaky\nSpline Interpolation IAF Population Decoder'
print fig_title
u_rec = func_timer(iaf.iaf_decode_spline_pop)([s1, s2], dur, dt,
                                                 [b1, b2], [d1, d2], [R1, R2],
                                                 [C1, C2])
pl.plot_compare(t, u, u_rec, fig_title,
예제 #3
0
b = 3.5  # bias
d = 0.7  # threshold
k = 0.01  # scaling factor

M = 5  # number of bins for fast decoding algorithm

try:
    asdm.asdm_recoverable(u, bw, b, d, k)
except ValueError('reconstruction condition not satisfied'):
    sys.exit()

output_count += 1
fig_title = 'Signal Encoded Using ASDM Encoder'
print fig_title
s = func_timer(asdm.asdm_encode)(u, dt, b, d, k)
pl.plot_encoded(t, u, s, fig_title,
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using ASDM Decoder'
print fig_title
u_rec = func_timer(asdm.asdm_decode)(s, dur, dt, bw, b, d, k)
pl.plot_compare(t, u, u_rec, fig_title,
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Threshold-Insensitive ASDM Decoder'
print fig_title
u_rec_ins = func_timer(asdm.asdm_decode_ins)(s, dur, dt, bw, b)
pl.plot_compare(t, u, u_rec_ins, fig_title,
                output_name + str(output_count) + output_ext)
예제 #4
0
a_list = map(list, np.reshape(np.random.exponential(0.003, N * M), (N, M)))
w_list = map(list, np.reshape(randu(0.5, 1.0, N * M), (N, M)))

T_block = T / 2.0
T_overlap = T_block / 3.0
fig_title = 'Signal Encoded Using Real-Time Delayed IAF Encoder'
print fig_title
s_list = func_timer(rt.iaf_encode_delay)(u_list, T_block, t_start, dt, b_list,
                                         d_list, k_list, a_list, w_list)

for i in xrange(M):
    for j in xrange(N):
        fig_title_out = fig_title + '\n(Signal #' + str(i+1) + \
                        ', Neuron #' + str(j+1) + ')'
        pl.plot_encoded(t_enc, u_list[i][k_start:k_end],
                        s_list[j][np.cumsum(s_list[j]) < T], fig_title_out,
                        output_name + str(output_count) + output_ext)
        output_count += 1

fig_title = 'Signal Decoded Using Real-Time Delayed IAF Decoder'
print fig_title
u_rec_list = func_timer(rt.iaf_decode_delay)(s_list, T_block, T_overlap, dt,
                                             b_list, d_list, k_list, a_list,
                                             w_list)

for i in xrange(M):
    fig_title_out = fig_title + ' (Signal #' + str(i + 1) + ')'
    pl.plot_compare(t_enc, u_list[i][k_start:k_end],
                    u_rec_list[i][0:k_end - k_start], fig_title_out,
                    output_name + str(output_count) + output_ext)
    output_count += 1
예제 #5
0
type2 = -1  # OFF-type neuron

a = 1.0 / 0.015
c = 1.0 / 3.0
h_list = [[0, 0], [0, 0]]
h_list[0][0] = lambda t: 0
h_list[0][1] = lambda t: -c * np.exp(-a * t) * ((a * t)**5 / 120.0 -
                                                (a * t)**7 / 5040.0) * (t >= 0)
h_list[1][0] = lambda t: c * np.exp(-a * t) * ((a * t)**5 / 120.0 -
                                               (a * t)**7 / 5040.0) * (t >= 0)
h_list[1][1] = lambda t: 0

fig_title = 'Signal Encoded Using Coupled IAF Encoder'
print fig_title
s_list = func_timer(iaf.iaf_encode_coupled)(u, dt, [b1, b2], [d1, d2],
                                            [k1, k2], h_list, [type1, type2])
output_count += 1
pl.plot_encoded(t, u, s_list[0], fig_title + ' #1',
                output_name + str(output_count) + output_ext)
output_count += 1
pl.plot_encoded(t, u, s_list[1], fig_title + ' #2',
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Coupled IAF Decoder'
print fig_title
u_rec = func_timer(iaf.iaf_decode_coupled)(s_list, dur, dt, [b1, b2], [d1, d2],
                                           [k1, k2], h_list)
pl.plot_compare(t, u, u_rec, fig_title,
                output_name + str(output_count) + output_ext)
예제 #6
0
u_gpu = gpuarray.to_gpu(u)
b_gpu = gpuarray.to_gpu(np.array([b1, b2]))
d_gpu = gpuarray.to_gpu(np.array([d1, d2]))
R_gpu = gpuarray.to_gpu(np.array([R1, R2]))
C_gpu = gpuarray.to_gpu(np.array([C1, C2]))

output_count += 1
fig_title = 'Signal Encoded Using Leaky IAF Encoder'
print fig_title
s_gpu, ns_gpu = func_timer(iaf_trig_cuda.iaf_encode_pop)(u_gpu, dt,
                                                         b_gpu, d_gpu, R_gpu, C_gpu)
                                                             
s = s_gpu.get()
ns = ns_gpu.get()
pl.plot_encoded(t, u, s[0,0:ns[0]], fig_title + ' #1',
                output_name + str(output_count) + output_ext)
output_count += 1
pl.plot_encoded(t, u, s[1,0:ns[1]], fig_title + ' #2',
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Leaky IAF Population Decoder'
print fig_title
u_rec = func_timer(iaf_trig_cuda.iaf_decode_pop)(s_gpu, ns_gpu, dur, dt, bw,
                                                     b_gpu, d_gpu, R_gpu,
                                                     C_gpu, M)
pl.plot_compare(t, u, u_rec, fig_title,
                output_name + str(output_count) + output_ext)

# Test ideal IAF algorithms:
u_gpu = gpuarray.to_gpu(u)
b_gpu = gpuarray.to_gpu(np.array([b1, b2]))
d_gpu = gpuarray.to_gpu(np.array([d1, d2]))
R_gpu = gpuarray.to_gpu(np.array([R1, R2]))
C_gpu = gpuarray.to_gpu(np.array([C1, C2]))

output_count += 1
fig_title = 'Signal Encoded Using Leaky IAF Encoder'
print fig_title
s_gpu, ns_gpu = func_timer(iaf_trig_cuda.iaf_encode_pop)(u_gpu, dt, b_gpu,
                                                         d_gpu, R_gpu, C_gpu)

s = s_gpu.get()
ns = ns_gpu.get()
pl.plot_encoded(t, u, s[0, 0:ns[0]], fig_title + ' #1',
                output_name + str(output_count) + output_ext)
output_count += 1
pl.plot_encoded(t, u, s[1, 0:ns[1]], fig_title + ' #2',
                output_name + str(output_count) + output_ext)

output_count += 1
fig_title = 'Signal Decoded Using Leaky IAF Population Decoder'
print fig_title
u_rec = func_timer(iaf_trig_cuda.iaf_decode_pop)(s_gpu, ns_gpu, dur, dt, bw,
                                                 b_gpu, d_gpu, R_gpu, C_gpu, M)
pl.plot_compare(t, u, u_rec, fig_title,
                output_name + str(output_count) + output_ext)

# Test ideal IAF algorithms:

b1 = 7.5  # bias
예제 #8
0
d_list = list(randu(0.15, 0.25, N))
k_list = list(0.01*np.ones(N))
a_list = map(list, np.reshape(np.random.exponential(0.003, N*M), (N, M)))
w_list = map(list, np.reshape(randu(0.5, 1.0, N*M), (N, M)))

fig_title = 'Signal Encoded Using Delayed IAF Encoder'
print fig_title
s_list = func_timer(iaf.iaf_encode_delay)(u_list, t_start, dt, b_list, d_list,
                                          k_list, a_list, w_list)

for i in xrange(M):
    for j in xrange(N):
        fig_title_out = fig_title + '\n(Signal #' + str(i+1) + \
                        ', Neuron #' + str(j+1) + ')'
        pl.plot_encoded(t_enc, u_list[i][k_start:k_end],
                        s_list[j][np.cumsum(s_list[j])<T],
                        fig_title_out,
                        output_name + str(output_count) + output_ext)
        output_count += 1
    
fig_title = 'Signal Decoded Using Delayed IAF Decoder'
print fig_title
u_rec_list = func_timer(iaf.iaf_decode_delay)(s_list, T, dt,
                                              b_list, d_list, k_list,
                                              a_list, w_list)

for i in xrange(M):
    fig_title_out = fig_title + ' (Signal #' + str(i+1) + ')'
    pl.plot_compare(t_enc, u_list[i][k_start:k_end],
                    u_rec_list[i][0:k_end-k_start], fig_title_out, 
                    output_name + str(output_count) + output_ext)
    output_count += 1
예제 #9
0
np.random.seed(0)

noise_power = None
fig_title = 'IAF input signal'
print fig_title
u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power)
pl.plot_signal(t, u, fig_title, output_dir + 'overview_input' + output_ext)

b = 3.5  # bias
d = 0.7  # threshold
R = np.inf  # resistance
C = 0.01  # capacitance

try:
    iaf.iaf_recoverable(u, bw, b, d, R, C)
except ValueError('reconstruction condition not satisfied'):
    sys.exit()

fig_title = 'Signal encoded by IAF neuron'
print fig_title
s = func_timer(iaf.iaf_encode)(u, dt, b, d, R, C)
pl.plot_encoded(t, u, s, fig_title,
                output_dir + 'overview_encoded' + output_ext)

fig_title = 'Decoded signal and reconstruction error'
print fig_title
u_rec = func_timer(iaf.iaf_decode)(s, dur, dt, bw, b, d, R, C)
pl.plot_compare(t, u, u_rec, fig_title,
                output_dir + 'overview_decoded' + output_ext)
예제 #10
0
noise_power = None
fig_title = 'IAF input signal';
print fig_title
u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power)
pl.plot_signal(t, u, fig_title, output_dir + 'overview_input' + output_ext)

b = 3.5     # bias
d = 0.7     # threshold
R = np.inf  # resistance
C = 0.01    # capacitance

try:
    iaf.iaf_recoverable(u, bw, b, d, R, C)
except ValueError('reconstruction condition not satisfied'):
    sys.exit()

fig_title = 'Signal encoded by IAF neuron'
print fig_title
s = func_timer(iaf.iaf_encode)(u, dt, b, d, R, C)
pl.plot_encoded(t, u, s, fig_title,
                output_dir + 'overview_encoded' + output_ext)

fig_title = 'Decoded signal and reconstruction error'
print fig_title
u_rec = func_timer(iaf.iaf_decode)(s, dur, dt, bw, b, d, R, C)
pl.plot_compare(t, u, u_rec, fig_title,
                output_dir + 'overview_decoded' + output_ext)