[G1-Sync] Manual knowledge update
This commit is contained in:
+133
-48
@@ -1,78 +1,163 @@
|
||||
---
|
||||
id: wiki-2026-0508-cnn
|
||||
title: CNN
|
||||
title: CNN (Convolutional Neural Network)
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [ConvNet, Convolutional Network]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [uncategorized]
|
||||
confidence_score: 0.95
|
||||
verification_status: applied
|
||||
tags: [deep-learning, computer-vision, cnn, neural-network]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: Python
|
||||
framework: PyTorch 2.5 / JAX
|
||||
---
|
||||
|
||||
---
|
||||
redirect_to: "[[데이터_사이언스_및_ML_엔지니어링]]"
|
||||
canonical_id: "wiki-2026-0507-029"
|
||||
---
|
||||
# CNN (Convolutional Neural Network)
|
||||
|
||||
# Redirect
|
||||
## 매 한 줄
|
||||
> **"매 CNN 의 핵심: spatial locality + parameter sharing + translation equivariance"**. 매 1989 LeCun LeNet 으로 시작, 매 2012 AlexNet 의 ImageNet breakthrough 가 deep-learning era 의 trigger. 매 2026 현재 ViT 의 주류 진입 unauthenticated, ConvNeXt-V2 / EfficientNet-V2 / RegNet 같은 modern CNN 의 efficiency 의 강점, 매 mobile / edge 의 dominant.
|
||||
|
||||
이 문서는 Canonical 문서인 통합되었습니다.
|
||||
모든 최신 지식과 세부 내용은 위 링크를 참조하십시오.
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
## 매 핵심
|
||||
|
||||
> 합성곱 신경망(CNN)은 학습 가능한 커널의 슬라이딩으로 공간적 지역성과 가중치 공유를 동시에 잡아, 이미지 같은 격자 데이터에서 표현 학습의 표준이 된 아키텍처다.
|
||||
### 매 architectural primitive
|
||||
- **Conv2d**: 매 sliding kernel — 매 (in_ch, out_ch, kH, kW) parameters.
|
||||
- **Pooling**: max/avg — 매 spatial downsampling.
|
||||
- **BatchNorm / GroupNorm**: 매 internal covariate shift mitigation.
|
||||
- **Residual connection (ResNet)**: 매 identity skip — 매 vanishing gradient solved.
|
||||
- **Depthwise-separable conv (MobileNet)**: 매 efficient — 매 9× FLOPs 감소.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
### 매 inductive biases
|
||||
- **Locality**: 매 nearby pixels correlated.
|
||||
- **Translation equivariance**: 매 object 의 위치 shift 도 같은 feature.
|
||||
- **Hierarchy**: 매 edge → texture → part → object.
|
||||
|
||||
**추출된 패턴:** 컨볼루션-비선형-풀링의 반복으로 receptive field를 점진 확장 → 저수준 엣지에서 고수준 객체로 추상화가 자연스럽게 형성됨.
|
||||
### 매 응용
|
||||
1. Image classification (ResNet, ConvNeXt, EfficientNet).
|
||||
2. Object detection (YOLO v11, RT-DETR backbone).
|
||||
3. Segmentation (U-Net, DeepLab v3+).
|
||||
4. Audio spectrograms, time-series, medical imaging.
|
||||
|
||||
**세부 내용:**
|
||||
- **핵심 연산**: Conv(공간 가중합) + Activation(ReLU 등) + Pool(다운샘플) + BatchNorm.
|
||||
- **대표 아키텍처**: LeNet→AlexNet→VGG→GoogLeNet→ResNet→DenseNet→EfficientNet→ConvNeXt.
|
||||
- **Residual connection**: 깊은 네트워크에서 그래디언트 소실을 우회하며 100층+ 학습을 가능케 함.
|
||||
- **한계**: 글로벌 컨텍스트 부족 → ViT/Hybrid 등으로 보완.
|
||||
- **응용**: 비전 외에도 음성·시계열·게놈 등 1D/3D 합성곱으로 확장.
|
||||
## 💻 패턴
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### Basic CNN block (PyTorch)
|
||||
```python
|
||||
import torch.nn as nn
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
class ConvBlock(nn.Module):
|
||||
def __init__(self, in_c, out_c, k=3, s=1):
|
||||
super().__init__()
|
||||
self.conv = nn.Conv2d(in_c, out_c, k, s, padding=k//2, bias=False)
|
||||
self.bn = nn.BatchNorm2d(out_c)
|
||||
self.act = nn.GELU()
|
||||
def forward(self, x):
|
||||
return self.act(self.bn(self.conv(x)))
|
||||
```
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
### Residual block (ResNet-style)
|
||||
```python
|
||||
class ResBlock(nn.Module):
|
||||
def __init__(self, c):
|
||||
super().__init__()
|
||||
self.b1 = ConvBlock(c, c)
|
||||
self.b2 = ConvBlock(c, c)
|
||||
def forward(self, x):
|
||||
return x + self.b2(self.b1(x))
|
||||
```
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
### Depthwise-separable (MobileNet)
|
||||
```python
|
||||
class DWSep(nn.Module):
|
||||
def __init__(self, in_c, out_c, s=1):
|
||||
super().__init__()
|
||||
self.dw = nn.Conv2d(in_c, in_c, 3, s, 1, groups=in_c, bias=False)
|
||||
self.pw = nn.Conv2d(in_c, out_c, 1, 1, 0, bias=False)
|
||||
self.bn = nn.BatchNorm2d(out_c)
|
||||
self.act = nn.GELU()
|
||||
def forward(self, x):
|
||||
return self.act(self.bn(self.pw(self.dw(x))))
|
||||
```
|
||||
|
||||
- **정보 상태:** draft
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
### ConvNeXt block (2026 modern CNN)
|
||||
```python
|
||||
class ConvNeXtBlock(nn.Module):
|
||||
def __init__(self, dim):
|
||||
super().__init__()
|
||||
self.dwconv = nn.Conv2d(dim, dim, 7, padding=3, groups=dim)
|
||||
self.norm = nn.LayerNorm(dim)
|
||||
self.pw1 = nn.Linear(dim, 4 * dim)
|
||||
self.act = nn.GELU()
|
||||
self.pw2 = nn.Linear(4 * dim, dim)
|
||||
def forward(self, x):
|
||||
i = x
|
||||
x = self.dwconv(x).permute(0, 2, 3, 1) # NCHW -> NHWC
|
||||
x = self.pw2(self.act(self.pw1(self.norm(x))))
|
||||
return i + x.permute(0, 3, 1, 2)
|
||||
```
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
### Training loop with mixed precision
|
||||
```python
|
||||
import torch
|
||||
from torch.cuda.amp import autocast, GradScaler
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
scaler = GradScaler()
|
||||
opt = torch.optim.AdamW(model.parameters(), lr=3e-4, weight_decay=0.05)
|
||||
for x, y in loader:
|
||||
opt.zero_grad()
|
||||
with autocast():
|
||||
loss = nn.functional.cross_entropy(model(x.cuda()), y.cuda())
|
||||
scaler.scale(loss).backward()
|
||||
scaler.step(opt)
|
||||
scaler.update()
|
||||
```
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
### Inference with TorchScript / compile
|
||||
```python
|
||||
model.eval()
|
||||
model = torch.compile(model, mode="reduce-overhead") # PyTorch 2.5+
|
||||
with torch.no_grad():
|
||||
out = model(x)
|
||||
```
|
||||
|
||||
- **과거 데이터와의 충돌:** 없음
|
||||
- **정책 변화:** 없음
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Small data (<10k images) | Pretrained ResNet-50 + finetune |
|
||||
| Mobile / edge | MobileNetV4 / EfficientNet-Lite |
|
||||
| SOTA on ImageNet | ConvNeXt-V2 or hybrid (CNN+ViT) |
|
||||
| Real-time detection | YOLOv11 (CSPDarknet backbone) |
|
||||
| Medical seg | U-Net++ or nnU-Net |
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
**기본값**: 매 timm 의 pretrained ConvNeXt-Tiny — 매 81%+ ImageNet, 매 28M params.
|
||||
|
||||
- **Parent:** [[10_Wiki/Topics]]
|
||||
- **Related:** *(TODO: 최소 2개)*
|
||||
- **Opposite / Trade-off:** *(TODO)*
|
||||
- **Raw Source:** 직접 입력
|
||||
## 🔗 Graph
|
||||
- 부모: [[Deep Learning]] · [[Neural Networks]]
|
||||
- 변형: [[ResNet]] · [[ConvNeXt]] · [[EfficientNet]] · [[MobileNet]]
|
||||
- 응용: [[Computer Vision]] · [[Object Detection]] · [[Image Segmentation]]
|
||||
- Adjacent: [[Vision Transformer]] · [[Attention Mechanisms]]
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 architecture sketch 의 generation, 매 training-loop boilerplate, 매 hyperparameter starting points, 매 debugging shape mismatches.
|
||||
**언제 X**: 매 SOTA tuning / benchmark 의 LLM 의존 X — 매 paper + timm 의 reference.
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
## ❌ 안티패턴
|
||||
- **Vanilla VGG-style 의 2026 사용**: 매 outdated — 매 ResNet/ConvNeXt 의 사용.
|
||||
- **No data augmentation**: 매 immediate overfit on small data.
|
||||
- **BatchNorm with batch size 1**: 매 statistic 무의미 — 매 GroupNorm 사용.
|
||||
- **Conv 후 immediate ReLU + BN order 의 inconsistent**: 매 BN→Act 의 standard.
|
||||
- **No mixed precision on modern GPU**: 매 free 2× speedup 의 손실.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (LeCun 1989, He et al. 2015 ResNet, Liu et al. 2022 ConvNeXt, 2024 ConvNeXt-V2).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — CNN fundamentals + ConvNeXt modern patterns |
|
||||
|
||||
Reference in New Issue
Block a user