innuce-spikify 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- innuce_spikify-0.1.0/AUTHORS +10 -0
- innuce_spikify-0.1.0/LICENSE +201 -0
- innuce_spikify-0.1.0/PKG-INFO +158 -0
- innuce_spikify-0.1.0/README.md +123 -0
- innuce_spikify-0.1.0/pyproject.toml +142 -0
- innuce_spikify-0.1.0/spikify/__init__.py +5 -0
- innuce_spikify-0.1.0/spikify/encoding/__init__.py +1 -0
- innuce_spikify-0.1.0/spikify/encoding/rate/__init__.py +5 -0
- innuce_spikify-0.1.0/spikify/encoding/rate/poisson_rate_algorithm.py +98 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/__init__.py +1 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/contrast/__init__.py +8 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/contrast/moving_window_algorithm.py +73 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/contrast/step_forward_algorithm.py +66 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/contrast/threshold_based_algorithm.py +65 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/contrast/zero_cross_step_forward_algorithm.py +64 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/deconvolution/__init__.py +7 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/deconvolution/bens_spiker_algorithm.py +84 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/deconvolution/hough_spiker_algorithm.py +77 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/deconvolution/modified_hough_spiker_algorithm.py +91 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/global_referenced/__init__.py +6 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/global_referenced/phase_encoding_algorithm.py +85 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/global_referenced/time_to_spike_algorithm.py +86 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/latency/__init__.py +5 -0
- innuce_spikify-0.1.0/spikify/encoding/temporal/latency/burst_encoding_algorithm.py +105 -0
- innuce_spikify-0.1.0/spikify/filtering/__init__.py +1 -0
- innuce_spikify-0.1.0/spikify/version.py +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2025] [Benedetto Leto, Gianvito Urgese, Vittorio Fra, Riccardo Pignari]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: innuce-spikify
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python package to conver signal data to spike data
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Keywords: artificial intelligence,neuromorphic computing,signal processing,education
|
|
7
|
+
Author: Benedetto Leto
|
|
8
|
+
Author-email: benedetto.leto@polito.it
|
|
9
|
+
Requires-Python: >=3.10,<4.0
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Provides-Extra: code-quality
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Provides-Extra: docs
|
|
28
|
+
Provides-Extra: release
|
|
29
|
+
Requires-Dist: numpy (>=2.1.0)
|
|
30
|
+
Requires-Dist: scipy (>=1.14.1)
|
|
31
|
+
Requires-Dist: torch (>=2.5.0)
|
|
32
|
+
Project-URL: Documentation, https://spikify.readthedocs.io/en/latest/
|
|
33
|
+
Project-URL: Repository, https://github.com/neuromorphic-polito/spikify
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# Spikify
|
|
37
|
+
|
|
38
|
+
Spikify is a Python package designed to transform raw signals into spike trains that can be fed into Spiking Neural Networks (SNNs). This package implements a variety of spike encoding techniques based on recent research to facilitate the integration of time-varying signals into neuromorphic computing frameworks.
|
|
39
|
+
|
|
40
|
+
## Introduction
|
|
41
|
+
|
|
42
|
+
Spiking Neural Networks (SNNs) are a novel type of artificial neural network that operates using discrete events (spikes) in time, inspired by the behavior of biological neurons. They are characterized by their potential for low energy consumption and computational cost, making them suitable for edge computing and IoT applications. However, traditional digital signals must be encoded into spike trains before they can be processed by SNNs.
|
|
43
|
+
|
|
44
|
+
This package provides a suite of spike encoding techniques that convert time-varying signals into spikes, enabling seamless integration with neuromorphic computing technologies. The encoding techniques implemented in this package are based on the research article: "Spike Encoding Techniques for IoT Time-Varying Signals Benchmarked on a Neuromorphic Classification Task" (Forno et al., 2022).
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
* Multiple Spike Encoding Techniques: Includes both rate-based and temporal encoding schemes
|
|
49
|
+
* Signal Preprocessing: Tools for preprocessing signals, including Gammatone and Butterworth filters
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
To install the Spikify package, use pip:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install innuce-spikify
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
Here is a simple example to get started:
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import numpy as np
|
|
65
|
+
|
|
66
|
+
# Generate a sinusoidal signal
|
|
67
|
+
time = np.linspace(0, 2 * np.pi, 100) # Time from 0 to 2*pi
|
|
68
|
+
amplitude = np.sin(time) # Sinusoidal signal
|
|
69
|
+
|
|
70
|
+
# Encode the raw signal into a spike train using Poisson Rate Coding
|
|
71
|
+
from spikify.encoding.rate import poisson_rate
|
|
72
|
+
|
|
73
|
+
# Set parameters for encoding
|
|
74
|
+
np.random.seed(0) # For reproducibility
|
|
75
|
+
interval_length = 2 # Length of the encoding interval
|
|
76
|
+
|
|
77
|
+
# Encode the sinusoidal signal
|
|
78
|
+
encoded_signal = poisson_rate(amplitude, interval_length)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For more detailed examples and usage, please refer to the [documentation](https://spikify.readthedocs.io/en/latest/).
|
|
82
|
+
|
|
83
|
+
## Encoding Techniques
|
|
84
|
+
|
|
85
|
+
This package implements several spike encoding families techniques, including:
|
|
86
|
+
|
|
87
|
+
### Rate Encoding
|
|
88
|
+
|
|
89
|
+
Rate encoding represents information by the firing rate of neurons. The higher the stimulus intensity, the higher the firing rate.
|
|
90
|
+
|
|
91
|
+
Algorithms:
|
|
92
|
+
* Poisson Rate
|
|
93
|
+
|
|
94
|
+
### Temporal Encoding
|
|
95
|
+
|
|
96
|
+
Temporal encoding conveys information through the precise timing of spikes. This family contains subcategories for contrast and deconvolution techniques:
|
|
97
|
+
|
|
98
|
+
#### Contrast-Based Temporal Encoding
|
|
99
|
+
|
|
100
|
+
Algorithms:
|
|
101
|
+
* Moving Window
|
|
102
|
+
* Step Forward
|
|
103
|
+
* Threshold-Based
|
|
104
|
+
* Zero-Cross Step Forward
|
|
105
|
+
|
|
106
|
+
#### Deconvolution-Based Temporal Encoding
|
|
107
|
+
|
|
108
|
+
Algorithms:
|
|
109
|
+
* Ben Spiker
|
|
110
|
+
* Hough Spiker
|
|
111
|
+
* Modified Hough Spiker
|
|
112
|
+
|
|
113
|
+
#### Global Referenced Encoding
|
|
114
|
+
|
|
115
|
+
Algorithms:
|
|
116
|
+
* Phase Encoding
|
|
117
|
+
* Time-to-Spike
|
|
118
|
+
|
|
119
|
+
#### Latency Encoding
|
|
120
|
+
|
|
121
|
+
Algorithms:
|
|
122
|
+
* Burst Encoding
|
|
123
|
+
|
|
124
|
+
Each technique has its advantages and can be selected based on the type of input data and the desired SNN architecture.
|
|
125
|
+
|
|
126
|
+
## Encoded Datasets
|
|
127
|
+
|
|
128
|
+
The following datasets have been selected to serve as examples for benchmarking spike train encoding techniques:
|
|
129
|
+
|
|
130
|
+
* WISDM Dataset: 20 Hz recordings of human activity through mobile and wearable inertial sensors
|
|
131
|
+
|
|
132
|
+
These datasets are preprocessed and converted into spike trains to evaluate the performance of different encoding techniques.
|
|
133
|
+
|
|
134
|
+
## Citation
|
|
135
|
+
|
|
136
|
+
If you use this framework in your research, please cite the following article:
|
|
137
|
+
|
|
138
|
+
```bibtex
|
|
139
|
+
@ARTICLE{
|
|
140
|
+
10.3389/fnins.2022.999029,
|
|
141
|
+
AUTHOR={Forno, Evelina and Fra, Vittorio and Pignari, Riccardo and Macii, Enrico and Urgese, Gianvito },
|
|
142
|
+
TITLE={Spike encoding techniques for IoT time-varying signals benchmarked on a neuromorphic classification task},
|
|
143
|
+
JOURNAL={Frontiers in Neuroscience},
|
|
144
|
+
VOLUME={16},
|
|
145
|
+
YEAR={2022},
|
|
146
|
+
URL={https://www.frontiersin.org/journals/neuroscience/articles/10.3389/fnins.2022.999029},
|
|
147
|
+
DOI={10.3389/fnins.2022.999029},
|
|
148
|
+
ISSN={1662-453X},
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Contributing
|
|
153
|
+
|
|
154
|
+
We welcome contributions from the community. Please see our CONTRIBUTING.rst file for more details on how to get involved.
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Spikify
|
|
2
|
+
|
|
3
|
+
Spikify is a Python package designed to transform raw signals into spike trains that can be fed into Spiking Neural Networks (SNNs). This package implements a variety of spike encoding techniques based on recent research to facilitate the integration of time-varying signals into neuromorphic computing frameworks.
|
|
4
|
+
|
|
5
|
+
## Introduction
|
|
6
|
+
|
|
7
|
+
Spiking Neural Networks (SNNs) are a novel type of artificial neural network that operates using discrete events (spikes) in time, inspired by the behavior of biological neurons. They are characterized by their potential for low energy consumption and computational cost, making them suitable for edge computing and IoT applications. However, traditional digital signals must be encoded into spike trains before they can be processed by SNNs.
|
|
8
|
+
|
|
9
|
+
This package provides a suite of spike encoding techniques that convert time-varying signals into spikes, enabling seamless integration with neuromorphic computing technologies. The encoding techniques implemented in this package are based on the research article: "Spike Encoding Techniques for IoT Time-Varying Signals Benchmarked on a Neuromorphic Classification Task" (Forno et al., 2022).
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
* Multiple Spike Encoding Techniques: Includes both rate-based and temporal encoding schemes
|
|
14
|
+
* Signal Preprocessing: Tools for preprocessing signals, including Gammatone and Butterworth filters
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
To install the Spikify package, use pip:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install innuce-spikify
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Here is a simple example to get started:
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import numpy as np
|
|
30
|
+
|
|
31
|
+
# Generate a sinusoidal signal
|
|
32
|
+
time = np.linspace(0, 2 * np.pi, 100) # Time from 0 to 2*pi
|
|
33
|
+
amplitude = np.sin(time) # Sinusoidal signal
|
|
34
|
+
|
|
35
|
+
# Encode the raw signal into a spike train using Poisson Rate Coding
|
|
36
|
+
from spikify.encoding.rate import poisson_rate
|
|
37
|
+
|
|
38
|
+
# Set parameters for encoding
|
|
39
|
+
np.random.seed(0) # For reproducibility
|
|
40
|
+
interval_length = 2 # Length of the encoding interval
|
|
41
|
+
|
|
42
|
+
# Encode the sinusoidal signal
|
|
43
|
+
encoded_signal = poisson_rate(amplitude, interval_length)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For more detailed examples and usage, please refer to the [documentation](https://spikify.readthedocs.io/en/latest/).
|
|
47
|
+
|
|
48
|
+
## Encoding Techniques
|
|
49
|
+
|
|
50
|
+
This package implements several spike encoding families techniques, including:
|
|
51
|
+
|
|
52
|
+
### Rate Encoding
|
|
53
|
+
|
|
54
|
+
Rate encoding represents information by the firing rate of neurons. The higher the stimulus intensity, the higher the firing rate.
|
|
55
|
+
|
|
56
|
+
Algorithms:
|
|
57
|
+
* Poisson Rate
|
|
58
|
+
|
|
59
|
+
### Temporal Encoding
|
|
60
|
+
|
|
61
|
+
Temporal encoding conveys information through the precise timing of spikes. This family contains subcategories for contrast and deconvolution techniques:
|
|
62
|
+
|
|
63
|
+
#### Contrast-Based Temporal Encoding
|
|
64
|
+
|
|
65
|
+
Algorithms:
|
|
66
|
+
* Moving Window
|
|
67
|
+
* Step Forward
|
|
68
|
+
* Threshold-Based
|
|
69
|
+
* Zero-Cross Step Forward
|
|
70
|
+
|
|
71
|
+
#### Deconvolution-Based Temporal Encoding
|
|
72
|
+
|
|
73
|
+
Algorithms:
|
|
74
|
+
* Ben Spiker
|
|
75
|
+
* Hough Spiker
|
|
76
|
+
* Modified Hough Spiker
|
|
77
|
+
|
|
78
|
+
#### Global Referenced Encoding
|
|
79
|
+
|
|
80
|
+
Algorithms:
|
|
81
|
+
* Phase Encoding
|
|
82
|
+
* Time-to-Spike
|
|
83
|
+
|
|
84
|
+
#### Latency Encoding
|
|
85
|
+
|
|
86
|
+
Algorithms:
|
|
87
|
+
* Burst Encoding
|
|
88
|
+
|
|
89
|
+
Each technique has its advantages and can be selected based on the type of input data and the desired SNN architecture.
|
|
90
|
+
|
|
91
|
+
## Encoded Datasets
|
|
92
|
+
|
|
93
|
+
The following datasets have been selected to serve as examples for benchmarking spike train encoding techniques:
|
|
94
|
+
|
|
95
|
+
* WISDM Dataset: 20 Hz recordings of human activity through mobile and wearable inertial sensors
|
|
96
|
+
|
|
97
|
+
These datasets are preprocessed and converted into spike trains to evaluate the performance of different encoding techniques.
|
|
98
|
+
|
|
99
|
+
## Citation
|
|
100
|
+
|
|
101
|
+
If you use this framework in your research, please cite the following article:
|
|
102
|
+
|
|
103
|
+
```bibtex
|
|
104
|
+
@ARTICLE{
|
|
105
|
+
10.3389/fnins.2022.999029,
|
|
106
|
+
AUTHOR={Forno, Evelina and Fra, Vittorio and Pignari, Riccardo and Macii, Enrico and Urgese, Gianvito },
|
|
107
|
+
TITLE={Spike encoding techniques for IoT time-varying signals benchmarked on a neuromorphic classification task},
|
|
108
|
+
JOURNAL={Frontiers in Neuroscience},
|
|
109
|
+
VOLUME={16},
|
|
110
|
+
YEAR={2022},
|
|
111
|
+
URL={https://www.frontiersin.org/journals/neuroscience/articles/10.3389/fnins.2022.999029},
|
|
112
|
+
DOI={10.3389/fnins.2022.999029},
|
|
113
|
+
ISSN={1662-453X},
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Contributing
|
|
118
|
+
|
|
119
|
+
We welcome contributions from the community. Please see our CONTRIBUTING.rst file for more details on how to get involved.
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "innuce-spikify"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A Python package to conver signal data to spike data"
|
|
5
|
+
authors = ["Benedetto Leto <benedetto.leto@polito.it>", "Gianvito Urgese <gianvito.urgese@polito.it>", "Vittorio Fra <vittorio.fra@polito.it>", "Riccardo Pignari <riccardo.pignari@polito.it>"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
# homepage = ""
|
|
8
|
+
repository = "https://github.com/neuromorphic-polito/spikify"
|
|
9
|
+
documentation = "https://spikify.readthedocs.io/en/latest/"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
keywords = ["artificial intelligence", "neuromorphic computing", "signal processing", "education"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 5 - Production/Stable",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Intended Audience :: Education",
|
|
16
|
+
"Intended Audience :: Science/Research",
|
|
17
|
+
"License :: OSI Approved :: Apache Software License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Topic :: Scientific/Engineering",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
packages = [
|
|
29
|
+
{ include = "spikify"}
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
exclude = ["docs", "tests", "examples"]
|
|
33
|
+
|
|
34
|
+
[tool.poetry.dependencies]
|
|
35
|
+
python = "^3.10"
|
|
36
|
+
numpy = ">=2.1.0"
|
|
37
|
+
scipy = ">=1.14.1"
|
|
38
|
+
torch = ">=2.5.0"
|
|
39
|
+
|
|
40
|
+
[tool.poetry.group.dev]
|
|
41
|
+
optional = true
|
|
42
|
+
|
|
43
|
+
[tool.poetry.group.dev.dependencies]
|
|
44
|
+
pytest = "^8.3.2"
|
|
45
|
+
pytest-cov = "^5.0.0"
|
|
46
|
+
|
|
47
|
+
[tool.poetry.group.code-quality]
|
|
48
|
+
optional = true
|
|
49
|
+
|
|
50
|
+
[tool.poetry.group.code-quality.dependencies]
|
|
51
|
+
pyproject-flake8 = '^7.0.0'
|
|
52
|
+
black = '^24.8.0'
|
|
53
|
+
docformatter = '^1.7.5'
|
|
54
|
+
pre-commit = "^3.8.0"
|
|
55
|
+
|
|
56
|
+
[tool.poetry.group.release]
|
|
57
|
+
optional = true
|
|
58
|
+
|
|
59
|
+
[tool.poetry.group.release.dependencies]
|
|
60
|
+
bump-my-version ="^0.26.0"
|
|
61
|
+
|
|
62
|
+
[tool.poetry.group.docs]
|
|
63
|
+
optional = true
|
|
64
|
+
|
|
65
|
+
[tool.poetry.group.docs.dependencies]
|
|
66
|
+
furo = '2024.8.6'
|
|
67
|
+
sphinx = '8.1.3'
|
|
68
|
+
sphinx-copybutton = '0.5.2'
|
|
69
|
+
sphinx-data-viewer = '0.1.5'
|
|
70
|
+
sphinx-needs = '4.1.0'
|
|
71
|
+
sphinx_design = '0.6.1'
|
|
72
|
+
sphinxcontrib-plantuml = '0.30'
|
|
73
|
+
sphinxcontrib-programoutput = '0.18'
|
|
74
|
+
numpydoc = '1.8.0'
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
[tool.black]
|
|
79
|
+
line-length = 120
|
|
80
|
+
|
|
81
|
+
[tool.docformatter]
|
|
82
|
+
recursive = true
|
|
83
|
+
wrap-summaries = 120
|
|
84
|
+
wrap-descriptions = 120
|
|
85
|
+
pre-summary-newline = true
|
|
86
|
+
blank = true
|
|
87
|
+
black = true
|
|
88
|
+
|
|
89
|
+
[tool.flake8]
|
|
90
|
+
count = true
|
|
91
|
+
statistics = true
|
|
92
|
+
show-source = true
|
|
93
|
+
max-line-length = 120
|
|
94
|
+
extend-ignore = ["E203"]
|
|
95
|
+
|
|
96
|
+
[tool.pytest.ini_options]
|
|
97
|
+
addopts = "-ra"
|
|
98
|
+
testpaths = [
|
|
99
|
+
"tests/*",
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
[tool.coverage.run]
|
|
103
|
+
branch = true
|
|
104
|
+
omit = [
|
|
105
|
+
"examples/*",
|
|
106
|
+
"docs/*",
|
|
107
|
+
"tests/*",
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
[tool.coverage.report]
|
|
112
|
+
|
|
113
|
+
exclude_also = [
|
|
114
|
+
"def __repr__",
|
|
115
|
+
"if self\\.debug",
|
|
116
|
+
"raise AssertionError",
|
|
117
|
+
"raise NotImplementedError",
|
|
118
|
+
|
|
119
|
+
# Don't complain if non-runnable code isn't run:
|
|
120
|
+
"if 0:",
|
|
121
|
+
"if __name__ == .__main__.:",
|
|
122
|
+
|
|
123
|
+
# Don't complain about abstract methods, they aren't run:
|
|
124
|
+
"@(abc\\.)?abstractmethod",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
ignore_errors = true
|
|
128
|
+
format = 'markdown'
|
|
129
|
+
|
|
130
|
+
[tool.coverage.xml]
|
|
131
|
+
output = "coverage/reports/coverage.xml"
|
|
132
|
+
|
|
133
|
+
[tool.poetry.extras]
|
|
134
|
+
dev = ["pytest", "pytest-cov"]
|
|
135
|
+
code-quality = ["pyproject-flake8", "black", "docformatter", "pre-commit"]
|
|
136
|
+
release = ["bump-my-version"]
|
|
137
|
+
docs = ["furo", "sphinx", "sphinx-copybutton", "sphinx-data-viewer", "sphinx-needs", "sphinx_design", "sphinxcontrib-plantuml", "sphinxcontrib-programoutput", "numpydoc"]
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
[build-system]
|
|
141
|
+
requires = ["poetry-core"]
|
|
142
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Encoding package."""
|