Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SNN-NCG
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
FOX_PUB
SNN-NCG
Commits
2891a561
Commit
2891a561
authored
6 months ago
by
Gaspard Goupy
Browse files
Options
Downloads
Patches
Plain Diff
comments and typo
parent
81cad827
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/readout.py
+2
-2
2 additions, 2 deletions
app/readout.py
spikenn/_impl.py
+1
-3
1 addition, 3 deletions
spikenn/_impl.py
spikenn/snn.py
+2
-2
2 additions, 2 deletions
spikenn/snn.py
spikenn/train.py
+5
-9
5 additions, 9 deletions
spikenn/train.py
with
10 additions
and
16 deletions
app/readout.py
+
2
−
2
View file @
2891a561
...
...
@@ -2,7 +2,7 @@ import sys
import
numpy
as
np
from
tqdm
import
tqdm
from
spikenn.snn
import
Fc
from
spikenn.train
import
S2STDPOptimizer
,
RSTDPOptimizer
,
S4NN
P
Optimizer
,
AdditiveSTDP
,
MultiplicativeSTDP
,
BaseRegularizer
,
CompetitionRegularizerTwo
,
CompetitionRegularizerOne
from
spikenn.train
import
S2STDPOptimizer
,
RSTDPOptimizer
,
S4NNOptimizer
,
AdditiveSTDP
,
MultiplicativeSTDP
,
BaseRegularizer
,
CompetitionRegularizerTwo
,
CompetitionRegularizerOne
from
spikenn.utils
import
DecisionMap
,
Logger
,
EarlyStopper
from
spikenn._impl
import
spike_sort
...
...
@@ -249,7 +249,7 @@ class Readout:
config_optim
=
config
[
"
optimizer
"
]
# BP-based rule
if
config_optim
[
"
method
"
]
==
"
s4nn
"
:
optim
=
S4NN
P
Optimizer
(
optim
=
S4NNOptimizer
(
network
=
network
,
t_gap
=
config_optim
[
"
t_gap
"
],
class_inhib
=
config_optim
.
get
(
'
class_inhib
'
,
False
),
# intra-class WTA, use when multiple neurons per class (e.g. with NCGs),
...
...
This diff is collapsed.
Click to expand it.
spikenn/_impl.py
+
1
−
3
View file @
2891a561
...
...
@@ -126,7 +126,6 @@ def class_inhibition(spks, pots, decision_map, max_time):
# SSTDP and S2-STDP weight update
# NOTE: Do not handle well dropout on the output neurons (contrary to R-STDP)
@njit
def
s2stdp
(
outputs
,
network_weights
,
y
,
decision_map
,
t_gap
,
class_inhib
,
use_time_ranges
,
max_time
,
ap
,
am
,
anti_ap
,
anti_am
,
stdp_func
,
stdp_args
):
n_layers
=
len
(
outputs
)
...
...
@@ -205,8 +204,7 @@ def s2stdp(outputs, network_weights, y, decision_map, t_gap, class_inhib, use_ti
# S4NN backward pass
# Almost similar to sstdp function, but in another function for the sake of clarity
# NOTE: Do not handle well dropout on the output neurons (contrary to R-STDP)
# Almost similar to sstdp code, but in another function for the sake of clarity
@njit
def
s4nn
(
outputs
,
network_weights
,
y
,
decision_map
,
t_gap
,
class_inhib
,
use_time_ranges
,
max_time
,
lr
):
n_layers
=
len
(
outputs
)
...
...
This diff is collapsed.
Click to expand it.
spikenn/snn.py
+
2
−
2
View file @
2891a561
...
...
@@ -116,9 +116,9 @@ class Fc(SpikingLayer):
self
.
input_size
=
input_size
self
.
n_neurons
=
n_neurons
# NOTE:
I
mplementation is in a function
augment
ed with Numba to
speed up
computations
on CPU
# NOTE:
The i
mplementation is in a function
optimiz
ed with Numba to
accelerate CPU
computations
.
def
__call__
(
self
,
sample
):
# Convert sample to SpikingDataset format (needed for multi-layer networks only)
# Convert
dense
sample to SpikingDataset format (needed for multi-layer networks only)
sample
=
self
.
convert_input
(
sample
)
# Select the employed thresholds
thresholds
=
self
.
thresholds_train
if
self
.
train_mode
else
self
.
thresholds
...
...
This diff is collapsed.
Click to expand it.
spikenn/train.py
+
5
−
9
View file @
2891a561
...
...
@@ -40,9 +40,8 @@ class S2STDPOptimizer(STDPOptimizer):
# NOTE:
# Implementation is in a function augmented with Numba to speed up computations on CPU
#
# code is not very clean, should be reworked.
# The implementation is in a function optimized with Numba to accelerate CPU computations.
# Hence, code is not very clean, should be reworked...
# However, Numba is not easily implementable in class methods.
def
__call__
(
self
,
outputs
,
target_ind
,
decision_map
):
n_layers
=
len
(
self
.
network
)
...
...
@@ -138,7 +137,7 @@ class RSTDPOptimizer(STDPOptimizer):
# S4NN optimizer (BP-based)
# NOTE: Can only train the output layer of the network
class
S4NN
P
Optimizer
:
class
S4NNOptimizer
:
__slots__
=
(
'
network
'
,
'
lr
'
,
'
t_gap
'
,
'
class_inhib
'
,
'
use_time_ranges
'
,
'
annealing
'
,
'
max_time
'
)
...
...
@@ -157,9 +156,8 @@ class S4NNPOptimizer:
# NOTE:
# Implementation is in a function augmented with Numba to speed up computations on CPU
#
# code is not very clean, should be reworked.
# The implementation is in a function optimized with Numba to accelerate CPU computations.
# Hence, code is not very clean, should be reworked...
# However, Numba is not easily implementable in class methods.
def
__call__
(
self
,
outputs
,
target_ind
,
decision_map
):
n_layers
=
len
(
self
.
network
)
...
...
@@ -296,7 +294,6 @@ class CompetitionRegularizerOne(BaseRegularizer):
# STDP inferface to store parameters and callable to core function
# TODO: Implementation not very clean, to rework
class
MultiplicativeSTDP
:
__slots__
=
(
'
beta
'
,
'
w_min
'
,
'
w_max
'
)
...
...
@@ -312,7 +309,6 @@ class MultiplicativeSTDP:
# STDP inferface to store parameters and callable to core function
# TODO: Implementation not very clean, to rework
class
AdditiveSTDP
:
__slots__
=
(
'
max_time
'
)
...
...
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