From 50749d8bce9f5f1721da317dfc377217ed06f296 Mon Sep 17 00:00:00 2001 From: Hammouda Elbez <hammouda.elbez@univ-lille.fr> Date: Sat, 19 Nov 2022 07:34:38 +0100 Subject: [PATCH] ReadMe & SpiNNaker folder updated --- README.md | 55 ++++++++++++++++++++++++++++++------ SpiNNaker/SpiNNakerRun.ipynb | 9 +----- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 97840fc..f8c9464 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,68 @@ # Progressive Layer-based Compression for Convolutional Spiking Neural Network -Here you find the code for the paper `Progressive Layer-based Compression for Convolutional Spiking Neural Network` ([link](https://hal.archives-ouvertes.fr/hal-03826823)) -## Requirement +Here you find the code for the paper `Progressive Layer-based Compression for Convolutional Spiking Neural Network` <!--([link](https://hal.archives-ouvertes.fr/hal-03826823))--> + +## CSNN + +### Requirement for the simulator * C++ compiler (version >= 14) * Cmake (version >= 3.1) * Qt4 (version >= 4.4.3) -## CSNN Installation and Build +### Building the binaries + Run the following commands inside CSNN folder: mkdir build cd build - cmake ../ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release + cmake ../ -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS='-std=c++11' make Don't forget to build again if you change the source code. -## How to use CSNN -Run MNIST Example: +### How to use CSNN +Once the `make` command is finished, you should see binary files which represent each simulation + +Run a simulation: + + ./[sim_name] x y + + args: + x = enable PP (pruning) [0 or 1] + y = enable DSWR (reinforcement) [0 or 1] + +To run MNIST simulation without compression and reinforcement: ./Mnist 0 0 +In `apps` folder you find the source code for each simulation where you can change the architecture, the network parameters, or activate the layerwise compression. + +## Going from CSNN to SpiNNaker +To transfer the learned weights from CSNN to SpiNNaker, we use the following command: + + ./Weight_extractor [binary file geenrated from a simulation] [name_layer] + +For example: + + ./Weight_extractor mnist_params conv1 +> `weights_conv1` is generated + +This will generate another binary file (named weights_[name_layer]) which contains only the weights of the selected layer . + ## How to use SpiNNaker scripts -To run the SpiNNaker scripts, please check the following link: +To setup the SpiNNaker board, please check the following link: http://spinnakermanchester.github.io/ +### Weights adaptation for PyNN and SpiNNaker + +in SpiNNaker folder: + +run the `ConvertTheWeights.ipynb` notebook to adapt the extracted weights from CSNN to a text format readable by PyNN. + +### Using the extracted weights with SpiNNaker + +Run the `SpiNNakerRun.ipynb` notebook to deploy the weights on the board and run simulation. + ## Folder structure ``` @@ -32,8 +70,9 @@ CSNN # The C++ Simulator of Convolutional Spiking Neural Network SpiNNaker # The scripts in python which are used for running on the SpiNNaker board ``` -# Citation +<!--# Citation If you found our work useful, please don't forget to cite: > Hammouda Elbez, Mazdak Fatahi. Progressive Layer-based Compression for Convolutional Spiking Neural Network. 2022. ⟨hal-03826823⟩ +--> \ No newline at end of file diff --git a/SpiNNaker/SpiNNakerRun.ipynb b/SpiNNaker/SpiNNakerRun.ipynb index 6aed942..b40d6a6 100644 --- a/SpiNNaker/SpiNNakerRun.ipynb +++ b/SpiNNaker/SpiNNakerRun.ipynb @@ -682,7 +682,7 @@ " if not os.path.exists(f'{path}/{str(now)}/{param_name}_{str(param_val)}'): # 1\n", " os.mkdir(f'{path}/{str(now)}/{param_name}_{str(param_val)}')\n", "\n", - " tests_name=['0_0_25_0.7_Zero_Removed_False_not_transposed', '1_1_25_0.7_Zero_Removed_False_not_transposed']\n", + " tests_name=['baseline', 'compressed']\n", "\n", " if not os.path.exists(f'{path}/{str(now)}/{param_name}_{str(param_val)}/{str(time)}'): # 2\n", " os.mkdir(f'{path}/{str(now)}/{param_name}_{str(param_val)}/{str(time)}')\n", @@ -714,13 +714,6 @@ "\n", " mySpiNNaker.sim.end()\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { -- GitLab