AI Computing Systems (EE219)

Shanghai Institute of Semiconductor Innovation (SISI)

Lab 1

Introduction

In this lab, you will implement NumPy forward inference and reverse-mode backpropagation for a CIFAR-10 CNN. Complete the inference first, then finish the required backpropagation task.

Lab Overview

Lab Tasks

Complete the TODOs in the provided notebook to implement NumPy forward inference and reverse-mode backpropagation for the CIFAR-10 CNN.

  • Implement the required forward operations for ReLU, convolution, max pooling, and fully-connected layers, and complete the CNN inference function.
  • Prepare the CIFAR-10 input as required and run inference using the released model weights.
  • Implement the required backward operations for the network, including input and weight gradients where applicable.
  • Implement the mean softmax cross-entropy loss and its logits gradient, then use them as the starting point for backpropagation.

Grading (100 pts): Forward inference and data preparation: 60 pts. Backpropagation: 40 pts.

Note: The description on this page provides only a summary of the lab. Please refer to the provided IPython notebook for the detailed requirements and instructions.

Lab Files

Download the Lab 1 files: EE219-Lab1.ipynb, cifar10_extraction.py, and model_2026fall.npz. Keep them together in Lab1/.

Run Lab 1 locally on the SISI-issued PC with an Intel Core Ultra 7 265K CPU and no discrete graphics card. MetaX computing resources are not provided for Lab 0 or Lab 1. The NumPy inference and backpropagation run on the CPU.

Use the ee219-cpu Conda environment created in Lab 0. Activate it in a Conda-enabled terminal and install any missing Lab 1 notebook dependencies:

conda activate ee219-cpu
python -m pip install numpy pillow imageio matplotlib jupyter ipykernel -i https://pypi.tuna.tsinghua.edu.cn/simple/

Run the notebook with Lab1/ as the working directory. Stage the raw CIFAR-10 Python batches under ./data/CIFAR10/cifar-10-batches-py/. The notebook runs cifar10_extraction.py to extract images and labels into ./data/CIFAR10/datasets/. If the batches are absent and your PC has network access, use %run cifar10_extraction.py --download as instructed in the notebook.

Use the released model_2026fall.npz with the specified CNN. Keep the native 32 × 32 RGB images; normalize pixels to [0, 1] and convert the input to (1, 3, 32, 32).

Requirements

Complete the provided EE219-Lab1.ipynb.

  1. Complete the code independently.
  2. Make sure your results are reproducible.
  3. Do not change the CNN structure, starter interfaces, or given code outside the TODOs.
  4. Do not add libraries beyond the imports provided in the notebook.

Bonus

Calculate the number of computations and parameters. Visualize your results directly in the outputs of your codes.

Submission

Before submitting:

  • Complete every required forward and backpropagation TODO.
  • Run the notebook from top to bottom and keep the required inference and backpropagation outputs.
  • Confirm preprocessing produces (1, 3, 32, 32) and every returned weight gradient matches its checkpoint tensor's shape.
  • Submit only the completed EE219-Lab1.ipynb; do not modify or submit the released checkpoints, CIFAR-10 data, or generated files.
  • If you use AI, please follow the requirements introduced in class and submit a separate AI report on Gradescope.

Important

Your notebook should be executable from top to bottom and should retain the required outputs when submitted.