Skip to content

Commit

Permalink
Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Pedro Dominguez-Morales authored Jun 17, 2016
1 parent 9cf03c6 commit 8fb1333
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions Main_SNN_Classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def loadWeights_2ndLayer(path):

lif_to_lif_output_proj = p.Projection(ssa, lif_output, p.FromListConnector(weighted_connections), target="excitatory")

#print weighted_connections

""" SECOND LAYER"""
second_lif_layer = p.Population(8, p.IF_curr_exp, cell_params_output, label='second_lif_layer')
Expand All @@ -198,12 +197,9 @@ def loadWeights_2ndLayer(path):

spikes_output_def = lif_output.getSpikes()
spikes_output_def_2nd = second_lif_layer.getSpikes()
#spikes_lif = lif.getSpikes()
weights = lif_to_lif_output_proj.getWeights()


#print weights

neuronFirings = [0 for i in range(8)]
neuronTotal = 0
neuronFirings_2nd = [0 for i in range(8)]
Expand Down Expand Up @@ -247,22 +243,6 @@ def loadWeights_2ndLayer(path):
elif x[0] == 7:
neuronFirings_2nd[7] += 1


def saveWeights2ndLayer(path):
with open(path, 'ab') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',')
spamwriter.writerow("---------DIV---------")
for i in range(len(neuronFirings)):
spamwriter.writerow([sys.argv[1], neuronFirings[i]])
def saveWeights3rdLayer(path):
with open(path, 'ab') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',')
spamwriter.writerow("---------DIV---------")
for i in range(len(neuronFirings_2nd)):
spamwriter.writerow([sys.argv[1], neuronFirings_2nd[i]])

#saveWeights2ndLayer("firingOutput2ndLayer.csv")
#saveWeights3rdLayer("firingOutput3rdLayer.csv")
print "\n\nSPIKES FIRED FOR EACH OUTPUT NEURON - LAYER 1. FILE No. "+ str(sys.argv[1])
print "Neuron0:", neuronFirings[0]
print "Neuron1:", neuronFirings[1]
Expand All @@ -283,23 +263,4 @@ def saveWeights3rdLayer(path):
print "Neuron5:", neuronFirings_2nd[5]
print "Neuron6:", neuronFirings_2nd[6]
print "Neuron7:", neuronFirings_2nd[7]
print "NeuronTotal", neuronTotal_2nd

#print weighted_connections_2ndLayer

def saveHit(path):
max = 0
rep = 0
for i in range(len(neuronFirings_2nd)):
if max < neuronFirings_2nd[i]:
max = neuronFirings_2nd[i]
rep = 0
elif max == neuronFirings_2nd[i]:
rep += 1
with open(path, 'ab') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',')
if neuronFirings_2nd[int(sys.argv[1])] == max and rep == 0:
spamwriter.writerow([int(sys.argv[1]), 1])
else:
spamwriter.writerow([int(sys.argv[1]), 0])
saveHit("hits.csv")
print "NeuronTotal", neuronTotal_2nd

0 comments on commit 8fb1333

Please sign in to comment.