Deep Learning
Deep Learning
A machine learning technique that uses multilayer neural networks. A core technology for image recognition, speech processing, and natural language processing.
Deep Learning
A machine learning technique that uses multilayer neural networks. A core technology for image recognition, speech processing, and natural language processing.
Deep Learning is a field of machine learning that uses artificial neural networks with many layers to automatically learn complex patterns and representations from data. The term "deep" means that many layers of the neural network are stacked, so that input data passes through multiple stages of nonlinear transformation and is progressively converted into more abstract features. Since AlexNet won the ImageNet competition in 2012, it has become a core technology of the modern AI revolution.
The core architectures of deep learning have evolved according to their purposes. CNNs (Convolutional Neural Networks) specialize in image recognition, RNNs/LSTMs in sequential data, and Transformers in natural language processing. As of 2024-2025, the Transformer architecture dominates almost every field, and has expanded from large language models (LLMs) such as GPT-4, Claude, and Gemini to the Vision Transformer (ViT) and the Audio Spectrogram Transformer.
Deep learning is trained through the Backpropagation algorithm. Input data is propagated forward to obtain predictions, the error is calculated with a loss function, and then the weights are updated by gradient descent. Modern deep learning secures training stability through techniques such as adaptive optimizers like Adam and AdamW, Learning Rate Schedulers, and Gradient Clipping. Distributed training (DDP, FSDP) and Mixed Precision are essential for training large-scale models.
Deep learning has become a core technology across industries. Most of modern technology is based on deep learning, including autonomous driving (Tesla FSD, Waymo), medical image analysis (cancer diagnosis), drug discovery (AlphaFold protein structure prediction), speech recognition (Whisper), recommendation systems (Netflix, YouTube), and generative AI (ChatGPT, Stable Diffusion). In 2025, agentic AI, multimodal models, and on-device AI are emerging as major trends.
Basic Deep Learning Structure in PyTorch (CNN Image Classification)
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
# 1. 모델 정의 (ResNet 스타일 블록 포함)
class DeepCNN(nn.Module):
def __init__(self, num_classes=10):
super().__init__()
self.features = nn.Sequential(
# Conv Block 1
nn.Conv2d(3, 64, 3, padding=1),
nn.BatchNorm2d(64),
nn.ReLU(inplace=True),
nn.MaxPool2d(2),
# Conv Block 2
nn.Conv2d(64, 128, 3, padding=1),
nn.BatchNorm2d(128),
nn.ReLU(inplace=True),
nn.MaxPool2d(2),
# Conv Block 3
nn.Conv2d(128, 256, 3, padding=1),
nn.BatchNorm2d(256),
nn.ReLU(inplace=True),
nn.AdaptiveAvgPool2d((1, 1))
)
self.classifier = nn.Sequential(
nn.Flatten(),
nn.Linear(256, 128),
nn.ReLU(inplace=True),
nn.Dropout(0.5),
nn.Linear(128, num_classes)
)
def forward(self, x):
x = self.features(x)
x = self.classifier(x)
return x
# 2. 데이터 로딩 및 전처리
transform = transforms.Compose([
transforms.RandomHorizontalFlip(),
transforms.RandomCrop(32, padding=4),
transforms.ToTensor(),
transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225))
])
train_dataset = datasets.CIFAR10(root='./data', train=True, download=True, transform=transform)
train_loader = DataLoader(train_dataset, batch_size=128, shuffle=True, num_workers=4)
# 3. 학습 루프 (현대적 관행 포함)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = DeepCNN(num_classes=10).to(device)
criterion = nn.CrossEntropyLoss()
optimizer = optim.AdamW(model.parameters(), lr=1e-3, weight_decay=0.01)
scheduler = optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=100)
for epoch in range(100):
model.train()
for images, labels in train_loader:
images, labels = images.to(device), labels.to(device)
optimizer.zero_grad()
outputs = model(images)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
scheduler.step()
print(f"Epoch {epoch+1}, Loss: {loss.item():.4f}, LR: {scheduler.get_last_lr()[0]:.6f}")
Transformer-Based Model (Using Hugging Face)
from transformers import AutoModelForSequenceClassification, AutoTokenizer
from transformers import TrainingArguments, Trainer
import torch
# 1. 사전학습 모델 로드 (BERT, RoBERTa 등)
model_name = "klue/bert-base"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(
model_name,
num_labels=2, # 이진 분류
problem_type="single_label_classification"
)
# 2. 데이터 토큰화
def tokenize_function(examples):
return tokenizer(
examples["text"],
padding="max_length",
truncation=True,
max_length=512
)
# 3. Fine-tuning 설정
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
per_device_train_batch_size=16,
per_device_eval_batch_size=32,
learning_rate=2e-5,
warmup_ratio=0.1,
weight_decay=0.01,
logging_steps=100,
evaluation_strategy="epoch",
save_strategy="epoch",
load_best_model_at_end=True,
fp16=True, # Mixed Precision 학습
)
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
)
# 4. 학습 및 추론
trainer.train()
# 추론 예시
inputs = tokenizer("딥러닝은 정말 강력한 기술입니다", return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
prediction = torch.argmax(outputs.logits, dim=1)
print(f"예측: {'긍정' if prediction == 1 else '부정'}")
| Model Scale | Number of Parameters | Training GPU | Training Cost (Estimated) |
|---|---|---|---|
| Small CNN (ResNet-18) | 11M | 1 RTX 3090 | A few hours, a few thousand KRW in electricity |
| BERT-base | 110M | 8 V100s | 4 days, several hundred thousand KRW |
| LLaMA-7B | 7B | 8 A100 80GB | 2-4 weeks, tens of millions of KRW |
| GPT-4 class | ~1.8T (estimated) | 25,000+ A100s | Hundreds of billions of KRW (estimated) |
| Fine-tuning (LoRA) | Less than 1% of the original | 1 RTX 4090 | A few hours, tens of thousands of KRW |
Practical Guide: Most business problems can be solved by fine-tuning a pretrained model. Using Hugging Face's PEFT (LoRA, QLoRA), you can fine-tune a 7B model even on a consumer GPU. Using an API is often more cost-efficient than training directly.
"Compared to the existing rule-based system, the deep learning model improved accuracy by 15%. The initial development cost is high, but maintenance for new cases is reduced, so long-term operating costs are expected to fall by 40%."
"With our current data scale, it is difficult to train from scratch. Fine-tuning a pretrained model is far more efficient. Let's start with BERT or ResNet as a baseline and adapt it efficiently with LoRA."
"The core of deep learning is Representation Learning. Traditional machine learning required humans to design features, but deep learning automatically learns hierarchical features from data. The lower layers extract low-level features such as edges and textures, and the higher layers extract high-level features such as objects and concepts."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
"Garbage In, Garbage Out" - No matter how sophisticated, a model cannot compensate for bad data. Before improving the model architecture, first resolve data quality verification, label accuracy, and class imbalance issues.
Rather than tuning the learning rate, batch size, number of layers, etc. aimlessly, apply a proven recipe first. For most problems, Adam/AdamW + Cosine Annealing + appropriate regularization is a good starting point.
1) Invest 40% of the total time in data quality verification. 2) First, understand the difficulty of the problem with a simple baseline (Linear, small MLP). 3) Start with a verified pretrained model and improve it gradually. 4) Record experiments systematically (MLflow, Weights & Biases) and keep them reproducible.