示例#1
0
C2 = Connection(L1,
                L1,
                allBut1(L1.num_neurons) * inh,
                params,
                rule = "static",
                wmin = inh,
                wmax = 0)

network = Network([Input, L1], [C1, C2])

''' Import and load saved weights '''
weight_file = open('weights.pickle', 'rb')
weights = pickle.load(weight_file)
weight_file.close()
network.set_weights(weights)

''' Record spiking activity of Layer 1 while showing it a bunch of images '''
print("Recording Spikes")
num_images = 1
time_step = 50
spikes = []
for i in tqdm(range(num_images)):
    network.populations[0].set_input(x_train[i])
    spikes.append(network.run(time_step, learning=False, record_spikes=True, pop_index=1).get("spikes"))
    network.rest()
spikes = np.reshape(spikes, (num_neurons, time_step*num_images))


''' Calculate correlation matrix from spiking activity '''
corr = np.zeros((len(spikes), len(spikes)))