---
id: wiki-2026-0508-spiking-neural-networks-snns
title: Spiking Neural Networks (SNNs)
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [snn, neuromorphic-nn, event-driven-nn, third-gen-nn]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [neuromorphic, snn, deep-learning, brain-inspired, low-power]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: python
  framework: snntorch-norse-lava
---

# Spiking Neural Networks (SNNs)

## 매 한 줄
> **"매 neurons fire discrete spikes — 매 event-driven, time-coded compute"**. SNN 은 매 biological neuron 의 spike train (LIF, Izhikevich) 을 모방한 third-generation neural network — 매 event-driven sparsity 의 ultra-low-power potential. 매 2026 의 Intel Loihi 2, IBM NorthPole, BrainScaleS-2 의 hardware 가 mature 단계.

## 매 핵심

### 매 vs ANN
- **ANN**: continuous activations, synchronous, dense compute.
- **SNN**: binary spikes, asynchronous events, sparse compute.
- **Time as a dimension**: 매 information 의 spike timing / rate 에 인코딩.
- **Power**: 매 event-driven 의 mW-scale (Loihi 2 의 ~74mW).

### 매 neuron model
- **LIF (Leaky Integrate-and-Fire)**: 매 simplest, hardware-friendly.
- **Izhikevich**: 매 cortical regular spiking 의 biologically richer.
- **Hodgkin-Huxley**: 매 ion-channel 수준 — 매 expensive.
- **AdEx**: adaptive exponential — 매 sweet spot.

### 매 encoding
- **Rate coding**: 매 spike count / unit time = real value.
- **Temporal coding**: 매 first-spike timing.
- **Phase / population coding**: 매 spike pattern.

### 매 training
- **STDP (Spike-Timing-Dependent Plasticity)**: 매 biologically plausible, unsupervised.
- **ANN-to-SNN conversion**: 매 trained ANN 의 weights 의 SNN 으로 transfer.
- **Surrogate gradient**: 매 backprop 의 의 spike non-differentiability 의 우회 — 매 2026 의 standard.
- **e-prop / online learning**: 매 BPTT 대체.

### 매 응용
1. **Edge AI** — 매 hearing aid, IoT sensor, drone (mW power).
2. **Event-camera vision** — 매 DVS / Prophesee sensor 의 native fit.
3. **Robotics** — 매 reflex / closed-loop control.
4. **BCI** — 매 spike-train 의 native processing.
5. **Neuromorphic computing** — 매 Loihi 2, NorthPole, SpiNNaker 2.

## 💻 패턴

### LIF neuron (snnTorch, surrogate gradient)
```python
import torch, torch.nn as nn, snntorch as snn

class SpikingMLP(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(784, 256)
        self.lif1 = snn.Leaky(beta=0.95, spike_grad=snn.surrogate.fast_sigmoid())
        self.fc2 = nn.Linear(256, 10)
        self.lif2 = snn.Leaky(beta=0.95, spike_grad=snn.surrogate.fast_sigmoid())

    def forward(self, x, T=25):
        m1 = self.lif1.init_leaky(); m2 = self.lif2.init_leaky()
        spk_rec = []
        for t in range(T):
            cur1 = self.fc1(x); spk1, m1 = self.lif1(cur1, m1)
            cur2 = self.fc2(spk1); spk2, m2 = self.lif2(cur2, m2)
            spk_rec.append(spk2)
        return torch.stack(spk_rec)  # [T, B, 10]
```

### Rate coding
```python
def rate_encode(image, T=25):  # image in [0,1]
    return (torch.rand(T, *image.shape) < image.unsqueeze(0)).float()
```

### Surrogate gradient (custom)
```python
class ATan(torch.autograd.Function):
    @staticmethod
    def forward(ctx, x):
        ctx.save_for_backward(x); return (x > 0).float()
    @staticmethod
    def backward(ctx, grad_out):
        x, = ctx.saved_tensors
        return grad_out * (1 / (1 + (math.pi * x) ** 2))
```

### ANN→SNN conversion (rate-based)
```python
# train ANN with ReLU normally, then replace ReLU with IF neurons
# scale weights so max activation == firing threshold
def convert(ann_model, calibration_loader):
    for layer in ann_model.modules():
        if isinstance(layer, nn.ReLU):
            replace_with_IF(layer, threshold=compute_max_act(layer, calibration_loader))
```

### Event camera + SNN (Prophesee)
```python
from metavision_core.event_io import EventDatReader
events = EventDatReader("recording.dat")
# events: (x, y, polarity, timestamp_us)
spike_tensor = events_to_spike_tensor(events, H=720, W=1280, T=25, dt=10000)
output = snn_model(spike_tensor)
```

### Loihi 2 deployment (Lava framework)
```python
from lava.proc.lif.process import LIF
from lava.proc.dense.process import Dense
from lava.magma.core.run_configs import Loihi2HwCfg

lif = LIF(shape=(256,), du=0.5, dv=0.5, vth=10)
dense = Dense(weights=W)
dense.s_out.connect(lif.a_in)
lif.run(condition=RunSteps(num_steps=100), run_cfg=Loihi2HwCfg())
```

### Norse (deep-learning style)
```python
import norse.torch as norse
model = nn.Sequential(
    norse.LIFCell(),
    nn.Linear(256, 10),
    norse.LIFCell(),
)
```

## 매 결정 기준
| 상황 | Approach |
|---|---|
| Edge inference (mW) | ANN→SNN convert + Loihi 2 / Akida |
| Event-camera | native SNN with surrogate gradient |
| GPU prototyping | snnTorch / Norse |
| Biological research | NEURON / Brian 2 |
| Scale-out neuromorphic | SpiNNaker 2 / BrainScaleS-2 |

**기본값**: 매 prototype 은 snnTorch + surrogate gradient. 매 deployment 는 ANN→SNN convert 후 Loihi 2 / Akida AKD1500.

## 🔗 Graph
- 부모: [[Neural-Networks]] · [[Neuromorphic-Computing]]
- 응용: [[Edge-AI]] · [[Brain-Computer-Interface]]
- Adjacent: [[SpiNNaker]]

## 🤖 LLM 활용
**언제**: literature summarization, surrogate gradient choice 추천, snnTorch boilerplate 생성.
**언제 X**: hardware-specific tuning (Loihi 2 의 chip-level 의 quirk) — 매 vendor docs / community 의 expert.

## ❌ 안티패턴
- **GPU-only mindset**: SNN 의 GPU 의 simulation 은 ANN 보다 slow. 매 power 이득 은 neuromorphic HW 에서.
- **Naive BPTT**: 매 spike 의 non-differentiability 무시. Surrogate gradient mandatory.
- **Too few timesteps**: 매 T=5 의 rate coding 의 information 부족. T=25~100 typical.
- **Ignoring conversion error**: ANN→SNN 의 accuracy drop. Calibration / threshold balancing.
- **Wrong neuron model**: 매 LIF 만 가지고 의 모든 task fit. Task 별 적합 model 선택.

## 🧪 검증 / 중복
- Verified (Maass 1997, snnTorch docs 2025, Intel Loihi 2 papers, Tavanaei et al. 2019 review, Eshraghian 2023).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — SNN fundamentals + 2026 neuromorphic stack |
