neuromap (convenience)¶
High-level helpers for the common workflow, importable directly from the
top-level package (import neuromap as nm).
neuromap.convenience
¶
Convenience functions for the simplified Neuromap workflow.
These high-level helpers wrap the core SDK classes to provide a streamlined developer experience for common tasks: encoding sensor data, configuring surrogate gradients, and exporting to hardware.
encode_sensor_data(data, num_steps=100, method='rate', **kwargs)
¶
Encode continuous data into spike trains.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
Input tensor. For |
required |
num_steps
|
int
|
Number of time steps (used by |
100
|
method
|
str
|
Encoding strategy - |
'rate'
|
**kwargs
|
Any
|
Extra arguments forwarded to the underlying encoder. |
{}
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Spike tensor. For |
Tensor
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If method is not recognised. |
compile_model(network, surrogate='atan')
¶
Inject an snnTorch surrogate gradient into all LIF layers.
This configures the network's neuron layers for training by replacing their surrogate gradient functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network
|
Any
|
A :class: |
required |
surrogate
|
str
|
Surrogate gradient name (see
:func: |
'atan'
|
quantize_and_export_to_spi(network, bit_resolution=4, path=None)
¶
Quantize model weights and export to .nmap format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network
|
Any
|
A :class: |
required |
bit_resolution
|
int
|
Bit-width for weight quantization. |
4
|
path
|
str | Path | None
|
If provided, save the |
None
|
Returns:
| Type | Description |
|---|---|
bytes | None
|
The |