[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -1,89 +1,177 @@
|
||||
---
|
||||
id: wiki-2026-0508-spiking-neural-networks-snns
|
||||
title: Spiking Neural Networks SNNs
|
||||
title: Spiking Neural Networks (SNNs)
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [SNN-001]
|
||||
aliases: [snn, neuromorphic-nn, event-driven-nn, third-gen-nn]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 1.0
|
||||
tags: [ai, neuroscience, snn, neuromorphic-computing, energy-Efficiency]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [neuromorphic, snn, deep-learning, brain-inspired, low-power]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-26
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: python
|
||||
framework: snntorch-norse-lava
|
||||
---
|
||||
|
||||
# Spiking Neural Networks (SNNs, 스파이킹 신경망)
|
||||
# Spiking Neural Networks (SNNs)
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "데이터가 아닌 '시간'과 '사건'으로 통신하는 3세대 인공신경망" — 생물학적 뉴런이 임계값에 도달했을 때만 짧은 전기 신호(Spike)를 내보내는 방식 그대로 정보를 처리하는 초저전력 신경망 아키텍처.
|
||||
## 매 한 줄
|
||||
> **"매 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 단계.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **추출된 패턴:** 정보를 연속적인 수치가 아닌 이산적인 스파이크의 '발생 시점'과 '빈도'에 인코딩하여, 변화가 있을 때만 연산함으로써 에너지 소모를 극도로 줄이는 이벤트 기반(Event-driven) 연산 패턴.
|
||||
- **세부 내용:**
|
||||
- **Leaky Integrate-and-Fire (LIF):** 입력을 시간에 따라 통합하다가 임계치를 넘으면 발화하고 초기화되는 기본 뉴런 모델.
|
||||
- **Temporal Coding:** 정보가 스파이크의 타이밍에 담겨 있어 시간적 선후 관계 처리에 매우 민감함.
|
||||
- **Neuromorphic [[Hardware|Hardware]]:** SNN 연산에 최적화된 하드웨어 (예: 인텔 Loihi, IBM TrueNorth)와 결합하여 효율성 극대화.
|
||||
- **Learning Algorithms:** 미분이 불가능한 스파이크 특성 때문에 전통적인 역전파 대신 STDP(Spike-Timing-Dependent Plasticity)와 같은 지역적 학습 규칙 활용.
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 부동 소수점 연산 중심의 기존 신경망(ANN)에 비해 정확도는 아직 낮을 수 있으나, 엣지 기기나 로보틱스 등 전력 제한이 엄격한 환경에서의 미래 기술로 주목받음.
|
||||
- **정책 변화:** Antigravity 프로젝트는 실시간 센서 데이터 모니터링 시 소모 전력을 줄이기 위해 SNN 기반의 이벤트 감지 알고리즘 도입을 연구 중.
|
||||
### 매 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).
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Hebbian-Learning|Hebbian-Learning]], Artificial-Neural-Networks, Neuroscience, Edge-AI
|
||||
- **Raw Source:** 10_Wiki/Topics/AI/Spiking-Neural-Networks-SNNs.md
|
||||
### 매 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.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 encoding
|
||||
- **Rate coding**: 매 spike count / unit time = real value.
|
||||
- **Temporal coding**: 매 first-spike timing.
|
||||
- **Phase / population coding**: 매 spike pattern.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### 매 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 대체.
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
### 매 응용
|
||||
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.
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
## 💻 패턴
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
### LIF neuron (snnTorch, surrogate gradient)
|
||||
```python
|
||||
import torch, torch.nn as nn, snntorch as snn
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
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())
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
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]
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Rate coding
|
||||
```python
|
||||
def rate_encode(image, T=25): # image in [0,1]
|
||||
return (torch.rand(T, *image.shape) < image.unsqueeze(0)).float()
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### 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))
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### 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))
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### 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)
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### 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
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
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]]
|
||||
- 변형: [[LIF-Neuron]] · [[Izhikevich-Neuron]] · [[Reservoir-Computing]]
|
||||
- 응용: [[Event-Cameras]] · [[Edge-AI]] · [[Brain-Computer-Interface]] · [[Robotic-Control]]
|
||||
- Adjacent: [[Loihi-2]] · [[NorthPole]] · [[SpiNNaker]] · [[STDP]] · [[Surrogate-Gradient]]
|
||||
|
||||
## 🤖 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 |
|
||||
|
||||
Reference in New Issue
Block a user