Dive into Deep Learning · §17.3
역시간 적분: 상미분방정식과 조상 연쇄
연속 방정식 · 확률 흐름 ODE · 오일러 스텝과 데이터 평균 · 경로 무관 좌표 · 조상 연쇄와 역시간 SDE
동기
실험 설정
이산화 오차와 신경망 근사 오차를 분리하기 위해 훈련된 두 TimeMLP(256, 3) 모델을 정확한 혼합 oracle과 대조한다:
loss over the last 1,000 steps: velocity 4.919, noise 0.537
ema_v): \mathbf{x}_t = (1 - t)\mathbf{x}_0 + t\boldsymbol\epsilon 을 따라 \boldsymbol\epsilon - \mathbf{x}_0 에 훈련되어 이론적 속도 하한선(\approx 4.91)에 도달한다.ema_eps): 분산 보존 스케줄을 따라 \boldsymbol\epsilon 에 훈련되어 이론적 잡음 하한선(\approx 0.54)에 도달한다.oracle): 임의의 (\mathbf{x}, \alpha_t, \sigma_t) 에서 닫힌 형태의 혼합 사후 평균 쌍 (\hat{\mathbf{x}}_0, \hat{\boldsymbol\epsilon}) 을 계산한다.확률 수송
\frac{\partial p_t(\mathbf{x})}{\partial t} = -\nabla \cdot \big(p_t(\mathbf{x})\,\mathbf{u}_t(\mathbf{x})\big)
조건부 구름에서 주변 밀도로
\mathbb{E}_{\mathbf{x}_0}\big[p_t(\mathbf{x} \mid \mathbf{x}_0)\,\mathbf{u}_t(\mathbf{x} \mid \mathbf{x}_0)\big] = p_t(\mathbf{x})\,\mathbf{u}_t(\mathbf{x})
확률 흐름 ODE의 기하학
\frac{d\mathbf{x}}{dt} = \mathbf{u}_t(\mathbf{x}), \qquad t: 1 \to 0
확률 흐름 ODE의 이산화
\mathbf{u}_1(\mathbf{x}_1) = \mathbf{x}_1 - \mathbb{E}[\mathbf{x}_0] \quad \Longrightarrow \quad \mathbf{x}_1 - \mathbf{u}_1(\mathbf{x}_1) = \mathbb{E}[\mathbf{x}_0]
정확한 속도장 궤적
원점 (0, 0) 과 (\pm 1.5, 0), (0, \pm 1.5) 의 다섯 고정 초기점에서 정확한 혼합 속도장 mix.velocity를 적분하면 다단계 곡률이 사전 분포를 어떻게 분할하는지 드러난다:
start 1 step 10 steps 100 steps
( 0.00, 0.00) (-0.50, -0.70) (-1.91, -1.27) (-1.98, -1.30)
( 1.50, 0.00) (-0.50, -0.70) ( 2.73, -1.34) ( 2.90, -1.36)
(-1.50, 0.00) (-0.50, -0.70) (-2.92, -1.38) (-3.06, -1.40)
( 0.00, 1.50) (-0.50, -0.70) (-0.11, 2.59) (-0.09, 2.77)
( 0.00, -1.50) (-0.50, -0.70) (-1.98, -2.06) (-2.05, -2.17)
스케줄 전반의 ODE 적분 통합
\bar{\mathbf{x}}_t = \frac{\mathbf{x}_t}{\alpha_t} = \mathbf{x}_0 + \bar\sigma_t\,\boldsymbol\epsilon, \qquad \frac{d\bar{\mathbf{x}}}{d\bar\sigma} = \hat{\boldsymbol\epsilon}(\bar{\mathbf{x}}, \bar\sigma)
보편 예측기와 오일러 루프
임의의 신경망 출력을 일치된 log-SNR에서 (\hat{\mathbf{x}}_0, \hat{\boldsymbol\epsilon}) 으로 매핑하는 make_pred와 ode_sample을 결합하면 어떤 솔버든 임의의 스케줄 위에서 훈련된 모델을 적분할 수 있다:
'eps'는 \hat{\mathbf{x}}_0 = (\mathbf{x}_t - \sigma_t\hat{\boldsymbol\epsilon})/\alpha_t 로 복원하므로 \alpha_1 = 0 에서 출발할 수 없으며, VP 경로에서는 \alpha_1 \approx 0.007 > 0 이다.실험적 ODE 수렴
2{,}000 개의 가우스 출발점에서 훈련된 선형 속도 신경망 ema_v에 ode_sample을 실행하면 K 가 커짐에 따라 이산화 오차가 어떻게 사라지는지 확인할 수 있다:

one step: mean [-0.511, -0.736] std [0.036, 0.027]
data: {'weights': [0.517, 0.292, 0.192], 'stray': 0.0145, 'spread': 0.488}
10 steps, network: {'weights': [0.522, 0.273, 0.206], 'stray': 0.0315, 'spread': 0.447}
100 steps, network: {'weights': [0.512, 0.278, 0.211], 'stray': 0.0125, 'spread': 0.475}
10 steps, oracle: {'weights': [0.522, 0.273, 0.206], 'stray': 0.019, 'spread': 0.459}
ode_sample against the loop on the exact field: 9e-05
10스텝 대 100스텝 실행 분석
확률적 역방향 마르코프 연쇄
\mathbf{x}_s \approx \underbrace{\Big[\mathbf{x}_t + \frac{\beta}{2}\nabla \log p_t + \sqrt{\beta}\,\mathbf{z}\Big]}_{\text{Langevin step } (h = \beta)} + \underbrace{\frac{\beta}{2}\big(\mathbf{x}_t + \nabla \log p_t\big)}_{\text{Flow ODE Euler step}}
Anderson 시간 역전 정리 (1982)
d\mathbf{x} = \big[\mathbf{f}(\mathbf{x}, t) - g(t)^2\nabla_{\mathbf{x}} \log p_t(\mathbf{x})\big]\,dt + g(t)\,d\bar{\mathbf{W}}
조상 연쇄 대 확률 흐름 ODE
20{,}000 개의 공유 가우스 출발점 \mathbf{x}_1 에서 200 조상 스텝(VP 위의 ema_eps)과 100 오일러 ODE 스텝(선형 경로 위의 ema_v)을 실행하고, 동일한 초기점 및 주입 잡음을 쓰는 정확한 oracle 실행과 1대1로 비교한다:

data: {'weights': [0.504, 0.299, 0.197], 'stray': 0.0103, 'spread': 0.476}
ancestral, network: {'weights': [0.502, 0.296, 0.202], 'stray': 0.0121, 'spread': 0.483}
ancestral, oracle: {'weights': [0.503, 0.296, 0.201], 'stray': 0.0121, 'spread': 0.482}
Euler, network: {'weights': [0.499, 0.305, 0.196], 'stray': 0.0127, 'spread': 0.471}
Euler, oracle: {'weights': [0.499, 0.304, 0.197], 'stray': 0.0107, 'spread': 0.474}
standard error of a weight: [0.0035, 0.0032, 0.0028]
ancestral: network and oracle end in different modes for 0.38% of the starts
Euler: network and oracle end in different modes for 0.21% of the starts
20,000-표본 실험 해석
N = 20{,}000 개 표본에서 모드 가중치의 이항 표준 오차는 \sqrt{w(1-w)/N} \approx 0.0035 이므로 분포 정확도를 날카롭게 검증할 수 있다:
경로, 타깃, 샘플러의 통합
문헌에 등장하는 모든 확산 및 플로 매칭 모델은 순방향 경로, 회귀 타깃, 역방향 적분기라는 세 가지 모듈형 선택으로 결정된다:
| 모델 계열 | 순방향 경로 | 훈련 타깃 | 역방향 샘플러 | 장 내 절 |
|---|---|---|---|---|
| 단일 수준 DSM | 고정 블러 \mathbf{x}_0 + \sigma\boldsymbol\epsilon | 스코어 -\boldsymbol\epsilon/\sigma | 고정 \sigma 랑주뱅 MCMC | §17.1 |
| NCSN (Song & Ermon, 2019) | 기하 VE 사다리 \tilde\sigma_i | 스코어 -\boldsymbol\epsilon/\tilde\sigma_i (가중치 \tilde\sigma_i^2) | 어닐링 랑주뱅 사다리 | §17.2 |
| DDPM (Ho 외, 2020) | 선형-\beta VP (\alpha_t^2 + \sigma_t^2 = 1) | 잡음 \boldsymbol\epsilon | 조상 연쇄 (역시간 SDE) | §17.2–17.3 |
| 플로 매칭 / 정류 흐름 | 선형 (1 - t)\mathbf{x}_0 + t\boldsymbol\epsilon | 속도 \boldsymbol\epsilon - \mathbf{x}_0 | 흐름 ODE 위의 오일러 / Heun | §17.2–17.5 |
| \mathbf{v}-예측 (Salimans & Ho) | 코사인 VP (\cos\frac{\pi t}{2}, \sin\frac{\pi t}{2}) | 각속도 \mathbf{v} = \alpha_t\boldsymbol\epsilon - \sigma_t\mathbf{x}_0 | ODE 또는 조상 샘플러 | §17.2, §17.6 |
| EDM (Karras 외, 2022) | VE 좌표 \bar{\mathbf{x}} = \mathbf{x}_0 + \bar\sigma\boldsymbol\epsilon | 선조건화된 깨끗한 점 \hat{\mathbf{x}}_0 | \bar\sigma^{1/\rho} 격자 위의 2차 Heun | §17.5–17.6 |
이해도 점검
역시간 적분과 샘플러 작동 원리에 대한 이해를 점검해 보자:
정답:
핵심 정리
| 개념 / 샘플러 | 수학적 방정식 | 구조적 보장 | 실용적 거동 |
|---|---|---|---|
| 연속 방정식 | \partial_t p_t = -\nabla \cdot (p_t \mathbf{u}_t) | 전체 확률 질량 보존 | \mathbf{u}_t = \mathbb{E}[\dot{\mathbf{x}}_t \mid \mathbf{x}_t] 가 정확한 모드 가중치 복원 |
| 확률 흐름 ODE | d\mathbf{x}/dt = \mathbf{u}_t(\mathbf{x}) (t: 1 \to 0) | 매끄러운 결정론적 전단사 사상 \mathbf{x}_1 \leftrightarrow \mathbf{x}_0 | 재현 가능한 표본, 잠재 코드, 정확한 가능도 |
| 1-스텝 오일러 붕괴 | \mathbf{x}_1 - \mathbf{u}_1(\mathbf{x}_1) = \mathbb{E}[\mathbf{x}_0] | t = 1 의 접선이 사전 평균을 향함 | 모든 출발점을 \mathbb{E}[\mathbf{x}_0] 로 붕괴; 곡선 경로는 \ge 10 스텝 필요 |
| 재스케일된 VE 좌표 | \bar{\mathbf{x}} = \mathbf{x}/\alpha_t, \;\bar\sigma = \sigma_t/\alpha_t | 임의의 경로에서 d\bar{\mathbf{x}}/d\bar\sigma = \hat{\boldsymbol\epsilon}(\bar{\mathbf{x}}, \bar\sigma) | 오일러 스텝 \mathbf{x}_s = \alpha_s\hat{\mathbf{x}}_0 + \sigma_s\hat{\boldsymbol\epsilon} (\eta = 0 의 DDIM) |
| DDPM 조상 스텝 | \frac{\mathbf{x}_t + \beta\nabla \log p_t}{\sqrt{1-\beta}} + \sqrt{\beta}\mathbf{z} | = \text{Flow ODE Euler step} + \text{Langevin step} | Anderson 역시간 SDE 이산화; 드리프트 오차 감쇠 |