# **Lab 0: Run MobileNet on GPU**
Before this lab begins, we strongly recommend you to watch the following videos to learn about basic machine learning knowledge and how to use PyTorch.
## **Due Date: 3/3 23:55**
**Note**: For those who have not been added to this course yet, your due date is **2/27 23:55**. Please send your work to angusyang.cs09@nycu.edu.tw.
## **Prerequisite**
Basic Machine Learning Knowledge:
- [Machine Learning 1](https://www.youtube.com/watch?v=Ye018rCVvOo)
- [Machine Learning 2](https://www.youtube.com/watch?v=bHcJCp2Fyxs)
- [Deep Learning](https://www.youtube.com/watch?v=Dr-WRlEFefw)
- [Back Propogation](https://www.youtube.com/watch?v=ibJpTrp5mcE)
- [Convolution](https://www.youtube.com/watch?v=OP5HcXJg2Aw&list=PLJV_el3uVTsMhtt7_Y6sgTHGHp1Vb2P2J&index=9)
PyTorch Tutorial
- [Tensor Basics](https://www.youtube.com/watch?v=exaWOE8jvy8&list=PLqnslRFeH2UrcDBWF5mfPGpqQDSta6VK4&index=2)
- [PyTorch Example](https://www.youtube.com/watch?v=Jy4wM2X21u0&list=PLhhyoLH6IjfxeoooqP9rhU3HJIAVAJ3Vz&index=3)
- [Save & Load Model](https://www.youtube.com/watch?v=g6kQl_EFn84&list=PLhhyoLH6IjfxeoooqP9rhU3HJIAVAJ3Vz&index=7)
- [Torch Compile](https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html)
- [Export Model in ONNX Format](https://pytorch.org/docs/stable/onnx_torchscript.html)
<span id="colab-tutorial"></span>
Colab Tutorial
- [Google Colab Tutoral by HUNG-YI LEE](https://speech.ee.ntu.edu.tw/~hylee/ml/ml2022-course-data/Colab%20Tutorial%202022.pdf)
Appendix
- [PyTorch Official Tutorial Playlist](https://www.youtube.com/watch?v=EMXfZB8FVUA&list=PLqnslRFeH2UrcDBWF5mfPGpqQDSta6VK4)
- [Create Custom Dataset for images](https://www.youtube.com/watch?v=ZoZHd0Zm3RY&list=PLhhyoLH6IjfxeoooqP9rhU3HJIAVAJ3Vz&index=9)
- [CNN Example](https://www.youtube.com/watch?v=wnK3uWv_WkU&list=PLhhyoLH6IjfxeoooqP9rhU3HJIAVAJ3Vz&index=4)
- [PyTorch 2.0](https://youtu.be/GYQTJnD-yjQ?si=Oeg6xPsjpXqpkl7V)
## **Introduction**
- In this assignment, you'll be using the *MobileNetV2* architecture to build an image classifier for the *CIFAR-10* dataset. Through this hands-on experience, you will learn about basic PyTorch and how to use ```torch.compile```, which is a new feature in PyTorch 2.0.
- Please download the code we provided and follow the hints to finish the code.
**Code Link**: [Link](https://drive.google.com/file/d/1EgfkNyt8LtI2mORdEL1hZWCgjYB1TGXZ/view?usp=sharing)
- You can run the code with **GPU** on Google Colab, please refer to [the colab tutorial above](#colab-tutorial) for the usage of it.
- If you want to run on your own resource, the environment setup in Google Colab are as followings:
- torch==2.1.0
- torchvision==0.16.0
## **Grading**
Part 1: *Train & Run MobileNet Classifier*
- Setup - 5%
- Data - 5%
- Model - 10%
- Optimization - 10%
- Training - 25%
- Export Model - 5%
- Inference - 10%
Part 2: *torch.compile*
- Training with torch.compile - 15%
- Inference with torch.compile - 15%
**Note**: Your accuracy must be higher than 92.5%
## **Hand-In Policy**
- **YourID.zip**
- YourID.ipynb
- YourID_model.pt **(trained in part 1)**
- YourID_onnx.png
## **Penalty**
- Wrong Format - 10%
- Late Submission - 10% per day