Code Examples

This section collects Jupyter notebooks with Python implementations of the adversarial attacks and defenses covered in the lectures. The notebooks accompany the lecture slides and serve as starting points for the homework assignments and the course project. Students are encouraged to use the GPUs provided by Google Colab for running the notebooks.

Each notebook can be viewed on this website, opened directly in Google Colab, or downloaded from the GitHub repository.

Adversarial Attacks and Defenses

Notebook Open in Colab
FGSM Attack in TensorFlow Colab
White-box Evasion Attacks in TensorFlow Colab
White-box Evasion Attacks in PyTorch Colab
Black-box Boundary Attack Colab
LLM Supervised Fine-tuning Colab
Jailbreak Attacks on LLMs Colab
Adversarial Training Colab
Attack on Network Intrusion Detection Colab

Hello World of ML

Introductory examples of training and evaluating machine learning models, from classical models on tabular data to fine-tuning large language models and vision-language models. A one-page overview is available as a PDF.

Year Notebook Open in Colab
2005 Logistic Regression on Iris Colab
2010 Random Forest on Breast Cancer Colab
2014 XGBoost on Titanic Colab
2015 MLPs on MNIST Colab
2018 ResNet on CIFAR-10 Colab
2021 DistilBERT on IMDb Colab
2023 Llama 2 on Alpaca Colab
2025 Qwen3 GRPO on MATH-500 Colab
2026 VLM Reasoning and Tool Use on MATH-500 Colab