Norse#

Norse is a deep learning simulator for spiking neural networks, built on PyTorch.

Import a NIR graph to Norse#

import norse.torch as norse
import torch

import nir

# Create a NIR Network
affine_weights = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
affine_bias = torch.tensor([1.0, 2.0])
lif_tau = torch.tensor([0.9, 0.8])
lif_r = torch.tensor([1.0, 1.0])
lif_v_leak = torch.tensor([0.0, 0.0])
lif_v_th = torch.tensor([1.0, 1.0])
nir_network = nir.NIRGraph.from_list(
    nir.Affine(affine_weights, affine_bias), nir.LIF(lif_tau, lif_r, lif_v_leak, lif_v_th)
)

# Import to Norse
norse_network = norse.from_nir(nir_network)

Export a NIR graph from Norse#

import norse.torch as norse
import torch

import nir

# Create a network
network = norse.SequentialState(norse.LIFCell(), torch.nn.Linear(1, 1))

# Export to nir
sample_data = torch.randn(1, 1)
nir_model = norse.to_nir(network, sample_data)

# Save to file
nir.write("nir_model.nir", nir_model)