SNABSuite  0.x
Spiking Neural Architecture Benchmark Suite
extract_from_diehl.py
Go to the documentation of this file.
1 # With this script we can extract the weights of the fully connected network
2 # and convert it into our format
3 # Data from:
4 # https://github.com/dannyneil/spiking_relu_conversion
5 # Diehl, P.U. and Neil, D. and Binas, J. and Cook, M. and Liu, S.C. and
6 # Pfeiffer, M. Fast-Classifying, High-Accuracy Spiking Deep Networks Through
7 # Weight and Threshold Balancing,
8 # IEEE International Joint Conference on Neural Networks (IJCNN), 2015
9 
10 import scipy.io
11 mat_data = scipy.io.loadmat("nn_98.84.mat")
12 
13 data = {}
14 data["netw"] = []
15 for layer in mat_data['nn'][0][0][13][0]:
16  layer_dict = {}
17  layer_dict["class_name"] = "Dense"
18  layer_dict["size"] = len(layer)
19  layer_dict["weights"] = layer.transpose().tolist()
20  data["netw"].append(layer_dict)
21 
22 import msgpack
23 with open("netw_diehl.msgpack", 'wb') as file:
24  msgpack.dump(data, file, use_single_float=True)