[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -1,91 +1,232 @@
|
||||
---
|
||||
id: wiki-2026-0508-free-energy-principle
|
||||
title: Free Energy Principle
|
||||
title: Free Energy Principle (FEP)
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-FEPP-001]
|
||||
aliases: [FEP, Karl Friston, active inference, predictive coding, surprise minimization]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [auto-reinforced, free-energy-principle, neuroscience, karl-friston, active-inference, perception]
|
||||
confidence_score: 0.88
|
||||
verification_status: applied
|
||||
tags: [neuroscience, philosophy, fep, active-inference, predictive-coding, friston, bayesian]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
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: NumPy / pymdp
|
||||
---
|
||||
|
||||
# [[Free-Energy-Principle|Free-Energy-Principle]]
|
||||
# Free Energy Principle (FEP)
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "놀라움을 줄이려는 생명의 몸부림: 모든 지능체는 외부 세상을 예측하고, 실제 감각 데이터와의 차이(Free Energy/Surprise)를 최소화하려는 방향으로 끊임없이 인식과 행동을 수정하며 항상성을 유지한다는 우주적 통찰."
|
||||
## 매 한 줄
|
||||
> **"매 self-organizing system 의 의 의 surprise (variational free energy) 의 minimize"**. Karl Friston (UCL). 매 perception (predictive coding) + 매 action (active inference) 의 unify. 매 neuroscience theory of everything (controversial). 매 modern: 매 RL / world model 의 connection.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
자유 에너지 원리(Free-Energy-Principle)는 신경과학자 칼 프리스턴(Karl Friston)이 제안한, 생명체와 지능의 작동 원리에 대한 대통합 이론입니다.
|
||||
## 매 핵심
|
||||
|
||||
1. **핵심 메커니즘 - Active Inference**:
|
||||
* **인식 수정**: 세상에 대한 나의 예측이 틀렸다면, 내 생각을 바꿈 (학습).
|
||||
* **행동 수행**: 세상을 내 예측에 맞게 바꿈 (예: 배고프면 음식을 찾아 먹어 예측된 영양 상태 실현).
|
||||
2. **왜 중요한가?**:
|
||||
* 에너지 소모를 최소화하면서도 복잡한 환경에서 살아남는 생명 지능의 '경제성'을 설명하며, 차세대 AI 아키텍처의 설계 영감이 됨. ([[Dopamine-Modeling|Dopamine-Modeling]]과 연결)
|
||||
### 매 statement
|
||||
- 매 brain (and body) 의 의 의 statistical model.
|
||||
- 매 free energy ≈ 매 prediction error.
|
||||
- 매 minimize via:
|
||||
1. **Update belief** (perception).
|
||||
2. **Act** (active inference).
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 뇌가 외부 자극을 수동적으로 처리하는 '연산 장치 정책'으로 보았으나, 자유 에너지 원리 정책은 뇌를 적극적으로 가설을 던지고 검증하는 '예측 기계 정책'으로 재정의함(RL Update).
|
||||
- **정책 변화(RL Update)**: 단순히 보상만 쫓는 강화학습 정책을 넘어, 세상을 더 잘 알기 위해(Surprise 감소) 정보를 수집하려는 동기가 부여된 '호기심 기반 에이전트 정책'의 수학적 수식으로 사용됨.
|
||||
### 매 vs RL
|
||||
- **RL**: 매 reward 의 maximize.
|
||||
- **FEP**: 매 surprise 의 minimize.
|
||||
- **Equivalence** (debated): 매 reward = -surprise.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- Neurobiology, [[Dopamine-Modeling|Dopamine-Modeling]], [[Exploration vs Exploitation|Exploration vs Exploitation]], [[Homeostasis (항상성)|Homeostasis (항상성)]], [[Cybernetics|Cybernetics]]
|
||||
- **Modern Tech/Tools**: Active Inference frameworks, Predictive coding models, Bio-inspired AI.
|
||||
---
|
||||
### 매 component
|
||||
- **Generative model**: 매 internal world model.
|
||||
- **Prior**: 매 expectation.
|
||||
- **Likelihood**: 매 sense → state.
|
||||
- **Posterior**: 매 belief update.
|
||||
- **Action**: 매 sense 의 expected 의 의 의 의 align.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 응용
|
||||
1. **Neuroscience**: 매 perception, attention, learning.
|
||||
2. **Psychiatry**: 매 schizophrenia, autism (precision-weighting).
|
||||
3. **Active inference RL**.
|
||||
4. **Robotics** (curiosity, exploration).
|
||||
5. **Computational psychiatry**.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### 매 critique
|
||||
- 매 too general 의 의 의 unfalsifiable.
|
||||
- 매 Lakatos progressive vs degenerate program.
|
||||
- 매 implementation 의 specific 의 X.
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
### Predictive coding (perception)
|
||||
```python
|
||||
import numpy as np
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
def predictive_coding_step(prior_mu, prior_var, observation, obs_var):
|
||||
"""매 Kalman-like update."""
|
||||
posterior_var = 1 / (1 / prior_var + 1 / obs_var)
|
||||
posterior_mu = posterior_var * (prior_mu / prior_var + observation / obs_var)
|
||||
prediction_error = observation - prior_mu
|
||||
return posterior_mu, posterior_var, prediction_error
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Variational free energy
|
||||
```python
|
||||
def variational_free_energy(q_mu, q_var, p_mu, p_var, obs, obs_var):
|
||||
"""매 F = KL[q||p] - log p(obs|s)."""
|
||||
kl = 0.5 * (np.log(p_var / q_var) + (q_var + (q_mu - p_mu)**2) / p_var - 1)
|
||||
log_likelihood = -0.5 * (np.log(2 * np.pi * obs_var) + (obs - q_mu)**2 / obs_var)
|
||||
return kl - log_likelihood
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Active inference (pymdp)
|
||||
```python
|
||||
import pymdp
|
||||
from pymdp.agent import Agent
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
# 매 simple 1-state, 1-modality agent
|
||||
A = np.eye(3) # 매 likelihood (state → obs)
|
||||
B = np.array([[[0.9, 0.1, 0], [0.1, 0.8, 0.1], [0, 0.1, 0.9]]]) # 매 transition (state, action)
|
||||
C = np.array([0, 0, 1]) # 매 prior preference (high obs 3)
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
agent = Agent(A=A, B=B, C=C)
|
||||
agent.infer_states(observation=[0])
|
||||
action = agent.sample_action()
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### Expected free energy (planning)
|
||||
```python
|
||||
def expected_free_energy(state_belief, action, A, B, C):
|
||||
"""매 EFE = epistemic value + pragmatic value."""
|
||||
next_state = B[action] @ state_belief
|
||||
expected_obs = A @ next_state
|
||||
|
||||
# 매 pragmatic (utility)
|
||||
pragmatic = (expected_obs * C).sum()
|
||||
|
||||
# 매 epistemic (info gain)
|
||||
epistemic = -np.sum(expected_obs * np.log(expected_obs + 1e-9))
|
||||
|
||||
return -pragmatic + epistemic # 매 minimize
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Predictive coding network (PyTorch)
|
||||
```python
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
|
||||
class PCLayer(nn.Module):
|
||||
def __init__(self, n):
|
||||
super().__init__()
|
||||
self.W = nn.Parameter(torch.randn(n, n) * 0.01)
|
||||
self.x = nn.Parameter(torch.zeros(n)) # 매 latent state
|
||||
|
||||
def forward(self, top_down, bottom_up):
|
||||
prediction = self.W @ self.x
|
||||
error_top = top_down - prediction
|
||||
error_bottom = bottom_up - self.x
|
||||
free_energy = (error_top ** 2).sum() + (error_bottom ** 2).sum()
|
||||
return free_energy
|
||||
```
|
||||
|
||||
### Curiosity (intrinsic reward = -surprise)
|
||||
```python
|
||||
class IntrinsicCuriosity:
|
||||
def __init__(self, model):
|
||||
self.model = model
|
||||
|
||||
def reward(self, state, action, next_state):
|
||||
predicted = self.model.predict(state, action)
|
||||
prediction_error = (predicted - next_state).abs().mean()
|
||||
return prediction_error # 매 high error = surprise = curiosity
|
||||
```
|
||||
|
||||
### Precision (attention)
|
||||
```python
|
||||
def precision_weighted_update(prediction_error, precision):
|
||||
"""매 attention = 매 high precision 의 weight."""
|
||||
return precision * prediction_error
|
||||
# 매 Friston: 매 schizophrenia = 매 precision 의 wrong
|
||||
```
|
||||
|
||||
### World model (similar to FEP)
|
||||
```python
|
||||
class WorldModel(nn.Module):
|
||||
"""매 Ha & Schmidhuber 2018."""
|
||||
def __init__(self, state_dim, action_dim):
|
||||
super().__init__()
|
||||
self.encoder = Encoder() # 매 obs → latent
|
||||
self.dynamics = nn.LSTM(latent_dim + action_dim, latent_dim)
|
||||
self.decoder = Decoder() # 매 latent → obs
|
||||
|
||||
def step(self, obs, action):
|
||||
latent = self.encoder(obs)
|
||||
next_latent, h = self.dynamics(torch.cat([latent, action]))
|
||||
predicted_obs = self.decoder(next_latent)
|
||||
return predicted_obs, next_latent
|
||||
```
|
||||
|
||||
### Hierarchical model
|
||||
```python
|
||||
class HierarchicalGenerativeModel:
|
||||
def __init__(self, levels):
|
||||
self.levels = levels # 매 each = (mu, var, dynamics)
|
||||
|
||||
def predict(self):
|
||||
# 매 top-down predictions
|
||||
for i in range(len(self.levels) - 1, 0, -1):
|
||||
self.levels[i-1].mu = self.levels[i].dynamics(self.levels[i].mu)
|
||||
|
||||
def update(self, obs):
|
||||
# 매 bottom-up errors
|
||||
for i in range(len(self.levels)):
|
||||
error = obs - self.levels[i].mu if i == 0 else self.levels[i-1].mu - self.levels[i].mu
|
||||
self.levels[i].mu += LR * error
|
||||
```
|
||||
|
||||
### Schizophrenia model (precision dysregulation)
|
||||
```python
|
||||
def schizophrenia_simulation(true_state, sensory_precision_low):
|
||||
"""매 low sensory precision → 매 prior 의 dominate → 매 hallucination."""
|
||||
sensory_precision = sensory_precision_low # 매 abnormally low
|
||||
prior_strength = 1.0
|
||||
posterior = (sensory_precision * sensory_input + prior_strength * prior) / (sensory_precision + prior_strength)
|
||||
return posterior # 매 dominated by prior
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Theoretical neuro | FEP framework |
|
||||
| Computational model | pymdp |
|
||||
| RL exploration | Curiosity (FEP-inspired) |
|
||||
| World model | Schmidhuber-style |
|
||||
| Psychiatry | Precision-weighting |
|
||||
|
||||
**기본값**: 매 FEP 의 high-level theory + 매 specific implementation = pymdp (active inference) or world model (RL).
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Computational-Neuroscience]] · [[Predictive-Processing]]
|
||||
- 변형: [[Active-Inference]] · [[Predictive-Coding]]
|
||||
- 응용: [[World-Model]] · [[Curiosity-Driven-RL]]
|
||||
- Adjacent: [[Bayesian-Brain]] · [[Default Mode Network (DMN)]] · [[Reinforcement-Learning]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 neuroscience research. 매 active inference RL.
|
||||
**언제 X**: 매 production engineering.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Theory of everything claim**: 매 unfalsifiable.
|
||||
- **FEP 의 RL 의 isomorphic 의 trust**: 매 detail 의 differ.
|
||||
- **Skip implementation**: 매 vague.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Friston papers, pymdp docs, Hohwy Predictive Mind).
|
||||
- 신뢰도 B+.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-04-20 | Auto-reinforced |
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — FEP + 매 predictive coding / pymdp / EFE / world model code |
|
||||
|
||||
Reference in New Issue
Block a user