- Configured a PyTorch-based deep learning environment
- Implemented data loading using
torchvision.datasets.ImageFolder - Added augmentation and normalization pipelines
- Organized the project structure (
googlenet.py,train.py,result/)
- Reconstructed the Inception modules following the original paper
- Implemented Auxiliary Classifiers to stabilize gradient flow
- Built the complete GoogLeNet architecture from scratch
- Ensured auxiliary outputs are used only during training, not inference
The POC dataset contains two folders:
POC_Dataset/
├── Training/
└── Testing/
- Training → split into Train : Validation = 90 : 10
- Train set → augmentation applied
- Validation / Test sets → only resize + normalize
- Testing folder was strictly used only at the very end → prevents data leakage and ensures proper generalization evaluation
The initial baseline training used a minimal pipeline:
- No augmentation
- No LR scheduler
- Direct train/test split
Baseline performance: ~50–56% accuracy
![]()
Issues detected:
- Unstable training
- High confusion in certain classes
- Sensitivity to class imbalance
To improve generalization, the following augmentations were added:
RandomHorizontalFlipRandomRotationColorJitter- Input normalization (
mean=0.5,std=0.5)
Result:
Validation accuracy increased significantly — reaching ~71%, with more stable loss curves.
This showed augmentation was essential for this medical dataset.
![]()
To build a more reliable training procedure:
- Added auxiliary classifier loss (GoogLeNet aux branches)
- Introduced StepLR scheduler
- Implemented Early Stopping (patience = 5)
- Created a full train/val/test split
- Added automatic logging (CSV)
- Enabled intermediate Confusion Matrix visualization
Effect:
- Training stabilized
- Overfitting became easier to detect
- Best-performing model was saved automatically
Confusion matrices were generated for both validation and final test sets.
- Chorionic_villi ↔ Trophoblastic_tissue showed noticeable misclassification
- Hemorrhage was classified relatively accurately
- Visualization clearly revealed class imbalance and inter-class similarity issues
These insights guided tuning decisions throughout development.
- Best Validation Accuracy: 87.23%
- Final Test Accuracy: 81.34%
-
Exported results include:
- Per-epoch validation confusion matrices
- Final test confusion matrix
- Training log CSV
- Best model checkpoint
Despite limited dataset size, the model shows strong improvement compared to the initial baseline.
| Metric | Score |
|---|---|
| Accuracy | 0.8134 |
| Macro Precision | 0.8214 |
| Macro Recall | 0.8045 |
| Macro F1-score | 0.8024 |
| Weighted F1-score | 0.8025 |
| Class | Precision | Recall | F1-score |
|---|---|---|---|
| Chorionic_villi | 0.8048 | 0.9359 | 0.8655 |
| Decidual_tissue | 0.8044 | 0.5186 | 0.6317 |
| Hemorrhage | 0.7619 | 0.9145 | 0.8317 |
| Trophoblastic_tissue | 0.9147 | 0.8489 | 0.8807 |
- Chorionic_villi and Trophoblastic_tissue achieved strong performance, each with high F1-scores (0.86–0.88).
- Hemorrhage was also classified accurately (F1 ≈ 0.83).
- Decidual_tissue exhibited noticeable misclassification (F1 ≈ 0.63), consistent with the Confusion Matrix.
- The overall metrics (~0.80 macro/weighted F1) indicate solid generalization despite the dataset’s small size and inter-class similarity.
- Auxiliary classifiers and data augmentation contributed significantly to training stability and performance.
-
Loss: CrossEntropyLoss + weighted auxiliary losses
-
Optimizer: Adam (lr = 1e-3)
-
Scheduler: StepLR(step_size=7, gamma=0.1)
-
Added tqdm progress bars
-
Enabled Early Stopping (patience = 5)
-
Saved best model to:
result/googlenet_poc_best.pt
-
Logged training loss and validation accuracy per epoch
-
Saved validation confusion matrices:
result/cm_val_epoch_XX.png -
Saved final test confusion matrix:
result/cm_test_final.png -
Exported training log:
result/training_log.csv
After training, the reserved Testing dataset was used for unbiased evaluation:
- Final Test Accuracy was computed
- Final Confusion Matrix generated
- Confirms generalization performance on unseen data
- Best Validation Accuracy: 87.23%
- Final Test Accuracy: 81.34%
- Some confusion between Chorionic_villi and Trophoblastic_tissue
- Hemorrhage was reliably classified
- Auxiliary classifiers helped stabilize training on a small dataset
ComputerVision/
├── googlenet.py
├── train.py
└── result/
├── cm_val_epoch_01.png
├── cm_val_epoch_02.png
├── cm_test_final.png
├── training_log.csv
└── googlenet_poc_best.pt
This project implements a complete training pipeline for classifying medical images using a reconstructed GoogLeNet architecture.
It includes:
- A clean train/validation/test workflow
- Auxiliary classifier integration
- Training stabilization techniques (scheduler, early stopping)
- Automated logging and visual analysis
- Rigorous evaluation on a dedicated hold-out test set
This work demonstrates practical deep learning engineering skills suitable for academic submissions or portfolio use.
이 프로젝트는 CIFAR-10 이미지 데이터셋을 이용하여 K-Nearest Neighbors (KNN) 분류기를 구현하고, 세 가지 실험 모드에 따라 모델 성능을 평가하는 과제용 코드이다.
| 기능 | 설명 |
|---|---|
| KNN 분류기 구현 | scikit-learn의 KNeighborsClassifier 사용 |
| 데이터셋 로드 | torchvision.datasets.CIFAR10로 자동 다운로드 및 변환 |
| 데이터 전처리 | StandardScaler로 픽셀 단위 정규화 (거리 기반 성능 향상) |
| 실험 모드 3종 | train/test, train/validation/test, 5-fold cross-validation |
| 평가지표 | Accuracy, Precision, Recall, F1-score (macro 평균) |
| 그래프 저장 | k 값에 따른 정확도 변화를 시각화 (matplotlib) |
knn_cifar10_assignment.py : 메인 코드 (모든 기능 포함)
plot_split_k.png : train/test 결과 그래프 (자동 생성)
plot_val_k.png : validation 결과 그래프 (자동 생성)
plot_cv_k.png : 5-fold cross-validation 결과 그래프 (자동 생성)
pip install torch torchvision scikit-learn matplotlib numpy
python knn_cifar10_assignment.py --mode split --k_list 5
--train_size 10000 --test_size 5000
사용 데이터: train 10,000 / test 5,000
결과 그래프: plot_split_k.png
python knn_cifar10_assignment.py --mode split_val --k_list 1 3 5 7 9
--train_size 10000 --val_size 5000 --test_size 5000
Validation set으로 best-k 선택
Test set에서 해당 k로 최종 평가
결과 그래프: plot_val_k.png
python knn_cifar10_assignment.py --mode cv --k_list 1 3 5 7 9 --folds 5
폴드마다 독립적인 전처리 및 평가 수행
k별 평균 정확도 ± 표준편차 계산
결과 그래프: plot_cv_k.png
| 모드 | 파일 이름 | 내용 |
|---|---|---|
split |
plot_split_k.png |
Test Accuracy vs k |
split_val |
plot_val_k.png |
Validation Accuracy vs k |
cv |
plot_cv_k.png |
5-Fold Mean Accuracy ± Std vs k |