Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Progressive Layer-based Compression for Convolutional Spiking Neural Network
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hammouda Elbez
Progressive Layer-based Compression for Convolutional Spiking Neural Network
Commits
bddee50b
Commit
bddee50b
authored
2 years ago
by
Hammouda Elbez
Browse files
Options
Downloads
Patches
Plain Diff
Added MnistForSpiNNaker
parent
cc8db4d6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CSNN-Simulator/apps/MnistForSpiNNaker.cpp
+78
-0
78 additions, 0 deletions
CSNN-Simulator/apps/MnistForSpiNNaker.cpp
with
78 additions
and
0 deletions
CSNN-Simulator/apps/MnistForSpiNNaker.cpp
0 → 100644
+
78
−
0
View file @
bddee50b
#include
"Experiment.h"
#include
"dataset/Mnist.h"
#include
"stdp/Simplified.h"
#include
"layer/Convolution.h"
#include
"Distribution.h"
#include
"execution/OptimizedLayerByLayer.h"
int
main
(
int
argc
,
char
**
argv
)
{
std
::
string
name
=
"mnist_spinn"
;
float
do_prune
=
atof
(
argv
[
1
]);
float
do_reinforcement
=
atof
(
argv
[
2
]);
if
(
do_prune
==
1
){
name
=
name
+
"_pruned"
;
}
if
(
do_reinforcement
==
1
){
name
=
name
+
"_reinforced"
;
}
Experiment
<
OptimizedLayerByLayer
>
experiment
(
argc
,
argv
,
name
);
experiment
.
template
input
<
LatencyCoding
>();
const
char
*
input_path_ptr
=
"../Datasets/MNIST/"
;
if
(
input_path_ptr
==
nullptr
)
{
throw
std
::
runtime_error
(
"Require to define INPUT_PATH variable"
);
}
std
::
string
input_path
(
input_path_ptr
);
experiment
.
template
add_train
<
dataset
::
Mnist
>(
input_path
+
"train-images.idx3-ubyte"
,
input_path
+
"train-labels.idx1-ubyte"
);
experiment
.
template
add_test
<
dataset
::
Mnist
>(
input_path
+
"t10k-images.idx3-ubyte"
,
input_path
+
"t10k-labels.idx1-ubyte"
);
float
th_lr
=
1.0
f
;
float
t_obj
=
0.50
f
;
float
alpha
=
0.05
f
;
float
alpha_p
=
0.01
f
;
float
alpha_n
=
0.005
f
;
float
beta_p
=
1.5
f
;
float
beta_n
=
2.5
f
;
float
prune_max_threshold
=
0.7
f
;
auto
&
fc1
=
experiment
.
template
push_layer
<
layer
::
Convolution
>(
"fc1"
,
28
,
28
,
400
);
fc1
.
template
parameter
<
float
>(
"annealing"
).
set
(
0.95
f
);
fc1
.
template
parameter
<
float
>(
"min_th"
).
set
(
1.0
f
);
fc1
.
template
parameter
<
float
>(
"t_obj"
).
set
(
t_obj
);
fc1
.
template
parameter
<
float
>(
"lr_th"
).
set
(
th_lr
);
fc1
.
template
parameter
<
float
>(
"doPrune"
).
set
(
do_prune
);
fc1
.
template
parameter
<
float
>(
"doReinforcement"
).
set
(
do_reinforcement
);
fc1
.
template
parameter
<
float
>(
"prune_max_threshold"
).
set
(
prune_max_threshold
);
fc1
.
template
parameter
<
Tensor
<
float
>
>
(
"w"
).
template
distribution
<
distribution
::
Uniform
>(
0.0
,
1.0
);
fc1
.
template
parameter
<
Tensor
<
float
>
>
(
"th"
).
template
distribution
<
distribution
::
Gaussian
>(
8.0
,
0.1
);
fc1
.
template
parameter
<
STDP
>(
"stdp"
).
template
set
<
stdp
::
Simplified
>(
alpha_p
,
alpha_n
,
beta_p
,
beta_n
);
alpha
=
alpha
*
2
;
auto
&
fc2
=
experiment
.
template
push_layer
<
layer
::
Convolution
>(
"fc2"
,
1
,
1
,
1600
);
fc2
.
template
parameter
<
float
>(
"annealing"
).
set
(
0.95
f
);
fc2
.
template
parameter
<
float
>(
"min_th"
).
set
(
1.0
f
);
fc2
.
template
parameter
<
float
>(
"t_obj"
).
set
(
t_obj
);
fc2
.
template
parameter
<
float
>(
"lr_th"
).
set
(
th_lr
);
fc2
.
template
parameter
<
float
>(
"doPrune"
).
set
(
do_prune
);
fc2
.
template
parameter
<
float
>(
"doReinforcement"
).
set
(
do_reinforcement
);
fc2
.
template
parameter
<
float
>(
"prune_max_threshold"
).
set
(
prune_max_threshold
);
fc2
.
template
parameter
<
Tensor
<
float
>
>
(
"w"
).
template
distribution
<
distribution
::
Uniform
>(
0.0
,
1.0
);
fc2
.
template
parameter
<
Tensor
<
float
>
>
(
"th"
).
template
distribution
<
distribution
::
Gaussian
>(
10.0
,
0.1
);
fc2
.
template
parameter
<
STDP
>(
"stdp"
).
template
set
<
stdp
::
Simplified
>(
alpha_p
,
alpha_n
,
beta_p
,
beta_n
);
experiment
.
add_train_step
(
fc1
,
25
);
experiment
.
add_train_step
(
fc2
,
25
);
experiment
.
run
(
10000
);
return
experiment
.
wait
();
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment