C.W.K.
Stream
Lesson 04 of 07 · published

Attention 과 Normalization

~8 min · layers

Level 0Keras 도제
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

MultiHeadAttention — Transformer 의 심장. num_heads, key_dim 인자. self-attention 은 query=key=value 같은 것 넘기기. cross-attention 은 다른 거 (encoder-decoder).

LayerNormalization — Transformer 에서 BatchNorm 자리 차지. batch 통계 안 쓰고 *feature 차원* 평균/분산. inference 시 batch 1 이어도 안정. 보통 attention/FFN block 의 *전* (pre-norm) 또는 *후* (post-norm) 에 박혀.

백엔드 노트:
⚙️ Backend Note

Code

# Multi-head attention (Transformer key component)
layers.MultiHeadAttention(
    num_heads=8,          # Number of attention heads
    key_dim=64,           # Dimension of each head
    flash_attention=True,  # Enable Flash Attention (3.7+)
)

External links

Exercise

MultiHeadAttention + LayerNormalization 으로 Transformer encoder block 짜. pre-norm 스타일 — norm → attn → +residual → norm → ffn → +residual. 작은 sanity 학습으로 gradient 흐름 확인.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.