Assignment 5

ViT-S LoRA Fine-tuning on CIFAR-100 & Adversarial Attacks with IBM ART

Overview

🎯 Q1: ViT-S + LoRA

Fine-tuned ViT-Small (pretrained on ImageNet) on CIFAR-100 with LoRA adapters. 10 experiments across rank/alpha combinations plus Optuna search.

⚔️ Q2: Adversarial Attacks

Implemented FGSM from scratch vs IBM ART on CIFAR-10 with ResNet-18. Trained ResNet-34 adversarial detectors for PGD and BIM attacks.

🔬 Optuna HPO

Used Optuna (20 trials) to find the best LoRA configuration. Best: r=13, α=16, dropout=0.061 achieving 89.35% test accuracy.

🐳 Dockerized

All experiments run inside Docker containers with CUDA support. Full reproducibility with requirements.txt and Dockerfile.

Q1: ViT-S LoRA Results

78.43%
Baseline (No LoRA)
38,500 trainable params
88.87%
Best Grid Search
r=2, α=8 — 75,364 params
89.35%
Optuna Best
r=13, α=16 — 278,116 params
+10.9%
LoRA Improvement
Over baseline accuracy

Test Results — All Configurations

LoRA Rank Alpha Dropout Test Accuracy Trainable Params
No 78.43%38,500
Yes220.1 87.52%75,364
Yes240.1 88.58%75,364
Yes280.1 88.87%75,364
Yes420.1 88.07%112,228
Yes440.1 88.32%112,228
Yes480.1 88.78%112,228
Yes820.1 88.40%185,956
Yes840.1 88.37%185,956
Yes880.1 88.74%185,956
Yes13160.061 89.35% (Optuna)278,116

Q2: Adversarial Attack Results

93.75%
ResNet-18 Clean Acc
CIFAR-10, 30 epochs
45.45%
FGSM Scratch (ε=0.005)
Accuracy drop: −48.3%
49.83%
FGSM ART (ε=0.005)
Accuracy drop: −43.9%
98.98%
BIM Detector
Detection accuracy

FGSM Perturbation Strength vs Accuracy

Epsilon Clean Accuracy FGSM Scratch FGSM IBM ART
0.00093.75%93.75%93.75%
0.00593.75%45.45%49.83%
0.01093.75%27.27%31.65%
0.02093.75%18.80%22.82%
0.04093.75%14.92%18.11%
0.08093.75%12.01%13.55%
0.10093.75%11.55%12.39%
0.15093.75%10.32%10.62%
0.20093.75%10.19%10.27%
0.30093.75%10.28%10.30%

Adversarial Detection Comparison

Attack Detection Accuracy Precision Recall F1-Score
PGD50.85% 0.59090.00660.0131
BIM98.98% 0.98030.99900.9895