🎯 Mục tiêu bài Quiz
Kiểm tra kiến thức của bạn qua các câu hỏi trắc nghiệm và bài tập thực hành!
✅ 18 câu hỏi trắc nghiệm (6 phần)
✅ 3 bài tập thực hành
✅ Yêu cầu: Hoàn thành bài 1-20
Thời gian: 30 phút | Độ khó: Tổng hợp | Đạt yêu cầu: ≥ 13/18 câu đúng
Phần 1: Neural Network Basics
Phần 2: Convolutional Neural Networks (CNN)
Phần 3: RNN & LSTM
Phần 4: Transformers & Attention
Phần 5: Transfer Learning
Phần 6: Deployment & Optimization
Phần 7: Bài tập thực hành
Bài tập 1: Xây dựng CNN cho Image Classification
Tình huống: Bạn cần xây dựng một mô hình CNN phân loại ảnh CIFAR-10 (10 classes, ảnh 32×32×3).
Hãy thiết kế kiến trúc CNN phù hợp, bao gồm:
- Các lớp Convolution, Pooling, Batch Normalization
- Dropout để regularization
- Fully connected layers ở cuối
1import tensorflow as tf2from tensorflow.keras import layers, models34model = models.Sequential([5 # Block 16 layers.Conv2D(32, (3,3), padding='same', activation='relu', input_shape=(32,32,3)),7 layers.BatchNormalization(),8 layers.Conv2D(32, (3,3), padding='same', activation='relu'),9 layers.BatchNormalization(),10 layers.MaxPooling2D((2,2)),11 layers.Dropout(0.25),1213 # Block 214 layers.Conv2D(64, (3,3), padding='same', activation='relu'),15 layers.BatchNormalization(),16 layers.Conv2D(64, (3,3), padding='same', activation='relu'),17 layers.BatchNormalization(),18 layers.MaxPooling2D((2,2)),19 layers.Dropout(0.25),2021 # Block 322 layers.Conv2D(128, (3,3), padding='same', activation='relu'),23 layers.BatchNormalization(),24 layers.MaxPooling2D((2,2)),25 layers.Dropout(0.25),2627 # Classifier28 layers.Flatten(),29 layers.Dense(256, activation='relu'),30 layers.BatchNormalization(),31 layers.Dropout(0.5),32 layers.Dense(10, activation='softmax')33])3435model.compile(36 optimizer='adam',37 loss='sparse_categorical_crossentropy',38 metrics=['accuracy']39)4041model.summary()42# Tổng ~600K params, đạt ~90% accuracy trên CIFAR-10Bài tập 2: Fine-tuning Pre-trained Model
Tình huống: Bạn có dataset ảnh y tế (2000 ảnh, 4 classes). Hãy viết code fine-tune ResNet50 pre-trained trên ImageNet cho bài toán này.
1from tensorflow.keras.applications import ResNet502from tensorflow.keras import layers, models34# 1. Load pre-trained ResNet50 (không lấy lớp FC cuối)5base_model = ResNet50(weights='imagenet', include_top=False, input_shape=(224,224,3))67# 2. Đóng băng các lớp pre-trained8base_model.trainable = False910# 3. Thêm classifier mới11model = models.Sequential([12 base_model,13 layers.GlobalAveragePooling2D(),14 layers.Dense(256, activation='relu'),15 layers.Dropout(0.5),16 layers.Dense(4, activation='softmax')17])1819# 4. Train classifier mới (feature extraction)20model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])21model.fit(train_data, epochs=10)2223# 5. Fine-tuning: mở khóa một số lớp cuối của ResNet5024base_model.trainable = True25for layer in base_model.layers[:-20]: # Đóng băng tất cả trừ 20 lớp cuối26 layer.trainable = False2728model.compile(29 optimizer=tf.keras.optimizers.Adam(1e-5), # Learning rate nhỏ30 loss='sparse_categorical_crossentropy',31 metrics=['accuracy']32)33model.fit(train_data, epochs=10)Bài tập 3: Export và Tối ưu Model
Tình huống: Bạn đã train xong model PyTorch và cần deploy lên production. Hãy viết code export model sang ONNX và áp dụng quantization.
1import torch2import torch.onnx34# 1. Export sang ONNX5dummy_input = torch.randn(1, 3, 224, 224)6torch.onnx.export(7 model,8 dummy_input,9 "model.onnx",10 opset_version=13,11 input_names=['input'],12 output_names=['output'],13 dynamic_axes={'input': {0: 'batch_size'}, 'output': {0: 'batch_size'}}14)1516# 2. Post-training Quantization (PyTorch)17quantized_model = torch.quantization.quantize_dynamic(18 model,19 {torch.nn.Linear}, # Quantize Linear layers20 dtype=torch.qint821)2223# 3. So sánh kích thước24import os25torch.save(model.state_dict(), "original.pth")26torch.save(quantized_model.state_dict(), "quantized.pth")27print(f"Original: {os.path.getsize('original.pth') / 1e6:.1f} MB")28print(f"Quantized: {os.path.getsize('quantized.pth') / 1e6:.1f} MB")2930# 4. ONNX Runtime inference31import onnxruntime as ort32session = ort.InferenceSession("model.onnx")33result = session.run(None, {"input": dummy_input.numpy()})📊 Đánh giá kết quả
| Số câu đúng | Đánh giá |
|---|---|
| 16-18 | 🌟 Xuất sắc! Bạn nắm vững Deep Learning |
| 13-15 | 👍 Tốt! Cần ôn lại một số chủ đề |
| 9-12 | 📚 Cần học thêm, xem lại các bài |
| < 9 | 🔄 Nên học lại từ đầu |
🎓 Hoàn thành khóa học!
🎉 Tuyệt vời! Bạn đã hoàn thành toàn bộ khóa học Deep Learning!
Tiếp theo: Hãy áp dụng kiến thức vào các dự án thực tế và tiếp tục nghiên cứu các kiến trúc mới nhất!
Bạn đã hoàn thành khóa học Deep Learning!
Kiến thức Deep Learning sẽ giúp bạn:
- 🧠 Xây dựng Neural Networks cho mọi bài toán
- 🖼️ Phát triển ứng dụng Computer Vision với CNN
- 📝 Xử lý ngôn ngữ tự nhiên với RNN, LSTM, Transformer
- 🚀 Deploy model lên production hiệu quả
Next steps:
- Thực hành với các dự án Computer Vision và NLP
- Tìm hiểu thêm về Generative AI (GANs, Diffusion Models)
- Tham gia Kaggle competitions
- Nghiên cứu các paper mới nhất trên arXiv
