whatpull/neuronface
0
1---2title: NeuronFace3emoji: ๐ง 4colorFrom: purple5colorTo: blue6sdk: docker7app_file: app.py8pinned: false9---10 11# NeuronFace12 13> **PatternKey API๋ ์์ ๋ฌด๋ฃ์
๋๋ค.**14> API ํ์ ์ ํ ์์ ยท ์คํ์์ค ยท MIT ๋ผ์ด์ ์ค15 16์๋ฌผํ์ LIF (Leaky Integrate-and-Fire) ๋ด๋ฐ๊ณผ ํผ์ง ๊ณ์ธต ๊ตฌ์กฐ ๊ธฐ๋ฐ์ ์ฐ๊ตฌ์ฉ ์ ๊ฒฝ๋ง ๋ฐฑ์๋. ๋ณ๋ ๋ธ๋ผ์ฐ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ [handface](https://github.com/whatpull/handface) (MediaPipe ๊ธฐ๋ฐ ์ ์ ์ค์ฒ/์์ ์ถ์ ) ๊ฐ ์ถ์ถํ ์ด๋ฒคํธ๋ฅผ ์๊ทน์ผ๋ก ๋ฐ์ ๋ฐํ ํจํด์ ์๋ฎฌ๋ ์ด์
ํฉ๋๋ค. FastAPI ์์์ ๋์ํ๋ฉฐ ๋ด๋ฐ ์ฝ์ด๋ ํ์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ง์ผ๋ก ๊ตฌํ๋์ด ์ถ๊ฐ ์์กด์ฑ์ด ์์ต๋๋ค.17 18## Quickstart19 20```bash21pip install -r requirements.txt22uvicorn app:app --reload --port 786023```24 25๊ธฐ๋ ํ [http://localhost:7860/docs](http://localhost:7860/docs) ์์ Swagger UI ๋ก ๋ชจ๋ ์๋ํฌ์ธํธ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.26 27## Docker28 29```bash30docker build -t neuronface .31docker run -p 7860:7860 neuronface32```33 34API ํค ๋ณดํธ๊ฐ ํ์ํ๋ฉด `NEURONFACE_API_KEY` ํ๊ฒฝ๋ณ์๋ฅผ ์ ๋ฌ:35 36```bash37docker run -p 7860:7860 -e NEURONFACE_API_KEY=your-secret neuronface38```39 40ํค๊ฐ ์ค์ ๋๋ฉด ๋ชจ๋ ์๋ํฌ์ธํธ์ `Authorization: Bearer <key>` ๋๋ `X-API-Key: <key>` ํค๋๊ฐ ํ์ํฉ๋๋ค. ๋ฏธ์ค์ ์ ์คํ ๋ชจ๋ (์ฐ๊ตฌ ํ๊ฒฝ ๊ธฐ๋ณธ๊ฐ).41 42## Version43 44`v0.2.4-zero-init-dynamic-cluster` (2026-05-10) โ zero-init dynamic cluster paradigm. `build_feature16_preset` default `n_cluster=0` (legacy 4-cluster baseline ํ๊ธฐ). ๋ชจ๋ cluster ์์ญ ์ฌ์ฉ์ ์
๋ ฅ ์์ญ `_grow_cluster` ์์ญ ๋์ spawn. ์ ๊ท endpoint `POST /networks/{id}/cluster/auto_train_or_spawn` โ vigilance evaluate + spawn-or-reinforce 1-call (์ฌ์ฉ์ catch: ์ฒซ ์
๋ ฅ ์์ญ cluster 0 first-spawn, ์ ๊ท distinct pattern ์์ญ cluster N+1 spawn, ๋์ผ ์
๋ ฅ ์์ญ ๊ธฐ์กด cluster ๊ฐํ). novel decision = (n_cluster=0 OR top_rate < min_winner_rate_hz=30 OR top_share < ฯ). ํ๊ท: test_stdp 29/29 PASS, e2e 3/3 PASS (n_cluster=4 ๋ช
์ fixture ์ ํฉ), n=20 spawn path 10/10 PASS.45 46`v0.2.3-anchor-sync` (2026-05-10) โ STDP_W_MAX 3-way SOT ์ ํฉ (CLAUDE/PAPER/test_stdp). SOT=40 (PAPER ยง5.2 ํ์ ์ ํฉ, Diehl-Cook 2015 normalized w_max 1.0 + base 0.2-0.5 ์ 3ร ratio). Phase 4 historic baseline ์ ์ง ๋ช
์ (README Roadmap L110). ํ๋ก ๋ณ๊ฒฝ 0, sanity recalc only.47 48 49`v0.2.2-cascade-restore` (2026-05-10) โ selectivity 0/4 โ 10/10 ํ๋ณต (B+17 V2 cascade wiring restore: `_grow_cluster` ์์ญ stale B+15 weight (0.30/5.0, 0.45/9.0) โ B+17 (0.40/7.0, 0.65/11.0, 0.70/12.0, 0.65/13.0) sync. audit round 4 fix #11). vigilance spawn ํ ์ ๊ท cluster cascade dead ์์ญ root cause ํด์.50 51`v0.2.1-dynamic-cluster` (2026-05-10) โ backend ART vigilance scaffolding (Carpenter-Grossberg ฯ share metric + `_grow_cluster` + dynamic `range(N)` training). `POST /networks/{id}/cluster/vigilance` (share metric, novelโspawn, max_clusters cap=64), `cluster_train_supervised` / `cluster_train_rstdp` ์์ญ dynamic cluster N (`_active_n_clusters` ์์ญ out_*_* prefix scan).52 53**v0.2.2 ๊ฒ์ฆ**: `tests/probes/probe_dynamic_cluster_n20.py` ์์ญ spawn 10/10 PASS + match 10/10 PASS. novel-then-train: `_grow_cluster` cascade weights B+17 sync ์ ํฉ (weight_changes_count=457, cluster 4 STDP ์ง์ ์ฆ๊ฑฐ) โ ๋จ inject self-match ๋ฏธ๋ฌ์ฑ, root cause = probe `[0.7]*16` uniform pattern ์์ญ cluster 1 ์ canonical IN[4..7] strong cascade ์์ญ ๋ถ์ผ์น (probe wiring ํ๊ณ, ๋ณ turn ์ถ์ ).54 55## API ๊ฐ์ (~70 endpoints, 2026-05-05 ํ์ฌ)56 57์ ์ฒด endpoint ๋ `/docs` ๋๋ [app.py](app.py) ์ฐธ์กฐ. ์๋๋ (a) handface frontend ๊ฐ ์ค์ ๋ก ํธ์ถํ๋ main path ์ (b) backend ์๋ ๊ตฌํ๋์ด ์์ผ๋ handface ๊ฐ ํธ์ถํ์ง ์๋ advanced/research path ๋ฅผ ์ ์งํ๊ฒ ๋ถ๋ฆฌํ๋ค.58 59### Main path โ handface ๊ฐ ์ค์ ๋ก ์ฌ์ฉ60 61handface ํด๋ผ์ด์ธํธ ([src/lib/backend/client.ts](https://github.com/whatpull/handface/blob/main/src/lib/backend/client.ts)) ๊ฐ ํธ์ถํ๋ 4 ๋จ๊ณ:62 63| ๋จ๊ณ | Method | Path | ์ค๋ช
|64|------|--------|------|------|65| 1 | `POST` | `/networks` | ์ ์๋ฎฌ๋ ์ด์
์ธ์
์์ฑ |66| 2 | `POST` | `/networks/{id}/presets/feature16` (๋๋ `/presets/basic`) | N3 cortical preset (default `v1_l4e_count=200` โ 472 neurons / OUT 32 cluster 4ร8 / WTA / NMDA; handface default `v1_l4e_count=50` โ 322 neurons) |67| 3a | `POST` | `/networks/{id}/inject_feature16` | 16-dim ์๊ทน + cascade fire (B+3 ์๋ต schema: `out_rates` 32 OUT Hz / `cluster_rates` 4-cluster mean Hz / `winner_cluster` argmax (idle ์ -1) / `winner_margin` (topโ2nd)/max(top,1.0) โ [0..1] / `synapses_changed` delta only โ handface state_payload round-trip ์ ๊ฐ ๋ชฉ์ ) |68| 3b | `POST` | `/networks/{id}/cluster_train_supervised` | cluster prefix `out_{c}_` 8 OUT ๋ชจ๋ supervisor batch ํ์ต (N3 ํต์ฌ ํ์ต path) |69| 3c | `POST` | `/networks/{id}/cluster_lock` | TRAINED cluster 8 OUT incoming ์๋
์ค freeze |70| 4 | `DELETE` | `/networks/{id}` | ์ธ์
์ญ์ |71 72์ด ๊ฒฝ๋ก๊ฐ handface ์ค์๊ฐ hand-gesture โ SNN ํ์ต ๋ฃจํ์ ์ ๋ถ์ด๋ค. cluster_lock ์ดํ backend STDP gate ๋ง frozen ์ผ๋ก ์ ํฉ๋๋ฉฐ, ์ถ๊ฐ reward-modulated ํ์ค๋ V_th regulation ์ ์ ์ฉ๋์ง ์๋๋ค.73 74### Advanced / research path โ backend ๊ตฌํ, handface ๋ฏธํธ์ถ75 76์๋ endpoint ๋ backend ์ ์ฌ์ค๋ก ๊ตฌํ๋์ด ์๊ณ `/docs` ์์ ์ง์ ํธ์ถ ๊ฐ๋ฅํ์ง๋ง, ํ์ฌ handface frontend ๋ ํธ์ถํ์ง ์๋๋ค. ํ์ reference / ๋ค๋ฅธ ํด๋ผ์ด์ธํธ / ํฅํ ํ์ฅ์ ์ํด ๋ณด์กด๋๋ค.77 78| Method | Path | ์ค๋ช
| handface ์ฌ์ฉ |79|--------|------|------|--------------|80| `POST` | `/networks/{id}/snapshot-weights` + `/rstdp-pulse` | R-STDP 2-step reward-modulated ์ฆํญ | ๋ฏธ์ฌ์ฉ |81| `POST` | `/networks/{id}/astrocytes/homeostasis_step` | per-neuron V_th regulation (Turrigiano 1998 ์ ํฉ, silence escape) | ๋ฏธ์ฌ์ฉ |82| `POST` | `/networks/{id}/homeostatic` | synaptic scaling | ๋ฏธ์ฌ์ฉ (client method ์ ์๋ง ์กด์ฌ, callsite 0) |83| `GET` | `/networks/{id}/training/snapshot` + `POST /training/load` | ํ์ต weight Save/Load | ๋ฏธ์ฌ์ฉ |84| `POST` | `/networks/{id}/reset` | ๋๋ ฅ๋ง reset (๊ตฌ์กฐ ๋ณด์กด) | ๋ฏธ์ฌ์ฉ |85| `POST` | `/networks/{id}/run` | ์ง์ ์๊ฐ๋งํผ ์๋ฎฌ๋ ์ด์
์งํ ํ ์คํ์ดํฌ ์์ ๋ฐํ | ๋ฏธ์ฌ์ฉ |86 87์ถ๊ฐ 90+ brain regions / verification suite / oscillation tools / paper export endpoint ๋ ๋์ผํ advanced ๋ฒ์ฃผ์ด๋ฉฐ `/docs` ์์ ํ์ธ ๊ฐ๋ฅํ๋ค.88 89## Project structure90 91```92neuronface/93โโโ app.py FastAPI ์๋ฒ94โโโ modules/95โ โโโ __init__.py96โ โโโ neuron.py LIF ๋ด๋ฐ + Synapse97โ โโโ monitoring.py SpikeMonitor (ring buffer + ๋ฐํ์จ)98โ โโโ network.py REST ์ธ์
์ฉ ํํ NeuralNetwork + Registry (๋ฐํ์ ํต์ฌ)99โ โโโ vectorized.py NumPy vectorization ๋ชจ๋ (์ต์
)100โ โโโ d1_db.py Cloudflare D1 marketplace ์ฐ๋101โ โโโ _archive/102โ โโโ brain.py ๊ณ์ธต ๊ตฌ์กฐ ๋ฐ๋ชจ (Network/Region/Column/Population)103โ โ runtime import 0, ํ์ reference ๋ณด์กด์ฉ archived (commit de4a658)104โโโ requirements.txt105โโโ Dockerfile106โโโ README.md107โโโ CLAUDE.md ๊ฐ๋ฐ์์ฉ ์์ธ ๊ฐ์ด๋ (์๋ฌผํ ์์, ์ ์ฝ, ํ๊ท ๊ธฐ์ค์ )108โโโ .gitignore109```110 111์ค๊ณ ์์นยท์๋ฌผํ์ ์์ยท๋ด๋ถ ์ ์ฝยท๊ฒฐ์ ๋ก ๊ธฐ์ค์ ์ [CLAUDE.md](CLAUDE.md) ์ฐธ์กฐ.112 113## Roadmap114 115- [x] Phase 1 โ LIF neurons116- [x] Phase 2 โ Cortical hierarchy117- [x] Phase 3 โ Monitoring layer (SpikeMonitor)118- [x] Phase 4 โ STDP (A_LTP=0.01, A_LTD=0.0105, W_MAX=320, tau=20ms) [historic baseline; SOT v0.2.2: A_LTP=0.0005, W_MAX=40, see PAPER ยง5.2 / Phase E commit 25ba2aa]119- [x] Phase 5 โ Neuromodulation (DA/ACh/5-HT/NE)120- [x] Phase 6 โ FastAPI backend121- [x] Phase 7 โ NumPy vectorization (`modules/vectorized.py`, ํ์ฑ ์ฌ๋ถ๋ ๋ชจ๋ ์ ํ)122- [x] P200 milestone โ 90+ brain regions, ~70 endpoints, 6 verification suite, 5 oscillation tools, 4 cluster preset, E2E pipeline, paper export123- [x] Session 53 (2026-05-05) โ N3 cortical preset (feature16: default `v1_l4e_count=200` โ 472 neurons; handface client default `v1_l4e_count=50` โ 322 neurons / OUT 32 cluster) + cluster_train_supervised + cluster_lock + R-STDP 2-step (snapshot-weights + rstdp-pulse) + per-neuron astrocyte homeostasis124 125## License126 127Apache License 2.0. See [LICENSE](./LICENSE) for details.128 