Skip to main content

Metrics for spiking neural networks.

Project description

snnmetrics

This package provides metrics that are specific to spiking neural networks. The API is similar to the one of torchmetrics. Currently in beta phase.

Number of synaptic operations (SynOps)

  1. Define a SynOps metric for each spiking layer by providing the fanout as float (mostly used for Linear layers) or tensor with dimensions (C,H,W), mostly used for conv layers.
    import snnmetrics as sm
    synops_layer1 = sm.SynOps(fanout=10.)
    synops_layer2 = sm.SynOps(fanout=100.)
    
  2. Get activations of intermediate spiking layers either from model directly or through forward hooks.
    y_hat, (layer1_activations, layer2_activations) = model(x)
    
  3. Pass activations to synops metrics to compute batch statistics. Sum over time if necessary, allowed shapes are (B,C) or (B,C,H,W). Batch statistics will be averaged across the batch dimension so you'll likely end up with non-integer synops.
    batch_stats_layer1 = synops_layer1(layer1_activations)
    synops_per_neuron = batch_stats_layer1['synops_per_neuron']
    synops = batch_stats_layer1['synops']
    
  4. At the end of the epoch, compute the average synops across all mini-batches.
    epoch_stats = synops_layer1.compute()
    epoch_synops = epoch_stats['synops']
    
  5. Before the start of the next epoch, reset the metric.
    synops_layer1.reset()
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snnmetrics-0.0.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

snnmetrics-0.0.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file snnmetrics-0.0.1.tar.gz.

File metadata

  • Download URL: snnmetrics-0.0.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for snnmetrics-0.0.1.tar.gz
Algorithm Hash digest
SHA256 368b4dedf53d96499c7025272e673bb4aaed26d6f580359e1a5eac5280bd49d9
MD5 706f431518f3b0951421450eec0369d4
BLAKE2b-256 9a415477ddb7ce996510072446f2999defa9069479cf38960f792300cdddc0f2

See more details on using hashes here.

File details

Details for the file snnmetrics-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: snnmetrics-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for snnmetrics-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b72b90d8b95e0bf9410972483c5405b0a5188d8347bf402eaf10646b18c3d0fc
MD5 5a19adebb13eebc51339608033d44c07
BLAKE2b-256 e2da62bed84bba4eba1e907df88a8eb20dff6118ff328b3649ee777d4741da8f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page