Assignment 1 · Fall 2026

An .ipynb file is a Jupyter notebook: it contains instructions, editable Python code and saved results. Each block is called a cell. You can work on A1 using JupyterLab in a browser or VS Code as a desktop app. Both run the code on your own computer; no GPU is needed.

First-time setup

  1. Download A1_Student_Package.zip and extract it. On Windows, right-click → Extract All; on macOS, double-click the ZIP. Keep the notebook, helper files and data/ together.
  2. Follow LOCAL_SETUP.md, Steps 1–4. This walks through installing Python, opening a command window, creating an environment and installing the packages. An environment keeps A1's Python tools in their own folder. You only do this installation once.
  3. Choose one editor below. You do not need to install both.

JupyterLab

After the setup, type this into the same terminal (command window):

python -m jupyter lab

Keep the terminal open. JupyterLab opens in your browser, but your code runs locally. If it does not open, copy the local URL printed in the terminal into the browser.

Double-click A1_Neural_Network_Fundamentals.ipynb in the file list. Choose DDA4220 A1 (CPU) when asked for a kernel, or use Kernel → Change Kernel. The kernel is the Python process that runs the notebook's cells.

VS Code

  1. Install the desktop app from code.visualstudio.com.
  2. Open its Extensions panel (the blocks icon on the left). Search for and install Python and Jupyter, both published by Microsoft.
  3. Choose File → Open Folder and select the extracted A1_Student_Package folder. If asked, trust this course-provided folder to enable code execution.
  4. Click A1_Neural_Network_Fundamentals.ipynb in the file list. At the top right, click Select Kernel and choose the assignment's .venv Python environment or DDA4220 A1 (CPU). If necessary, choose Select Another Kernel → Python Environments to find .venv.
  5. Start at Section 0. Its first code cell prints the Python and PyTorch versions so you can check that the environment is selected correctly.

The full VS Code notebook guide shows these controls.

Work through the notebook

Save and submit

Save regularly with Ctrl+S (Windows/Linux) or Cmd+S (macOS). Before submitting, restart the kernel and run the completed notebook from top to bottom: use Kernel → Restart Kernel and Run All Cells in JupyterLab, or Restart followed by Run All in VS Code. Fix any errors, then save again. Keep the results and figures; do not clear outputs.

Submit these three files from your assignment folder:

Do not submit the original ZIP, data folder or .venv environment.

Optional: Google Colab

If Colab is accessible on your network and you prefer to work online, follow COLAB_SETUP.md. It explains uploading both the notebook and its helper/data package, and downloading your work. Colab is not required for A1.

Run A1 on your own computer

You will install Python, make a separate environment for A1, then use JupyterLab or VS Code to open the notebook. Internet access is needed during installation; the MNIST data are included.

1. Install Python

Install Python 3.13 unless Python 3.12 or 3.13 is already installed. Open the official downloads page, choose a Python 3.13 release, and download the installer for your operating system. Run it with the standard options. On Windows, keep the Python launcher enabled and select Add Python to PATH if offered.

Python 3.12 also works: if you already use it, replace 3.13 with 3.12 in the commands below. Avoid a pre-release version.

2. Open a terminal in the assignment folder

A terminal is a window where you type commands and press Enter. The commands below go there, not into notebook cells. Run one line at a time and wait for it to finish.

Unzip A1_Student_Package.zip and locate the folder containing the .ipynb, requirements-a1.txt and data/.

Windows: open that folder in File Explorer. Click the address bar, type cmd, and press Enter. This opens Command Prompt in the right folder. Use Command Prompt for the Windows commands below.

macOS: open Terminal from Applications → Utilities. Type cd (including the space), drag the extracted assignment folder from Finder into the terminal window, then press Enter. cd means “change folder.”

Linux: open a terminal in the extracted folder using your file manager. Use python3 in place of python3.13 below, and check that it reports Python 3.12 or 3.13. On Ubuntu/Debian, install python3-venv and python3-pip with your system package manager if they are missing.

3. Create and activate an environment

An environment keeps this assignment's Python packages together in a folder named .venv. Create it once; activate it whenever you open a new terminal to work on A1.

Windows Command Prompt:

py -3.13 --version
py -3.13 -m venv .venv
.venv\Scripts\activate.bat

macOS:

python3.13 --version
python3.13 -m venv .venv
source .venv/bin/activate

After activation, the prompt usually starts with (.venv). Keep using this terminal for the following steps. If the Python command is not found, finish installing Python and reopen the terminal.

4. Install the packages

Follow the official PyTorch installation page. Select Stable, your operating system, Pip and Python; choose CPU where a compute-platform choice is offered. Copy the displayed command into your activated terminal and run it to install PyTorch and torchvision.

Then run:

python -m pip install -r requirements-a1.txt
python -m ipykernel install --user --name dda4220-a1 --display-name "DDA4220 A1 (CPU)"

The first command installs the notebook tools. The second makes your environment available by the name DDA4220 A1 (CPU). Wait for both to finish.

5. Choose your notebook editor

Return to README.md and follow either the JupyterLab or VS Code instructions. Both use the environment you just created. Start at Section 0 in the notebook and run the version-check cell.

Next time

JupyterLab: open a terminal in the same assignment folder, activate .venv using the activation line above, then run python -m jupyter lab.

VS Code: reopen the assignment folder and notebook, and select the same .venv kernel.

You do not need to create the environment or reinstall the packages each time.

If imports fail, check the selected kernel. If a helper or data file is missing, check that you extracted the complete package and opened the notebook from that folder. A NotImplementedError in an exercise means its TODO still needs your code.

Optional: use Google Colab

Use this option only if Google Colab is accessible on your network. It runs Python online and requires a Google account. Local JupyterLab or VS Code works without access to Colab.

Open a working copy

  1. Keep the downloaded A1_Student_Package.zip and unzip a copy on your computer.
  2. Open Colab, sign in, choose File → Upload notebook, and select A1_Neural_Network_Fundamentals.ipynb from the extracted folder.
  3. Choose File → Save a copy in Drive and work in that copy. Rename it A1_Neural_Network_Fundamentals.ipynb using the title at the top.
  4. Under Runtime → Change runtime type, use CPU / no hardware accelerator. A runtime is the computer session executing your code.

Upload the helpers and data

Uploading the notebook does not include its helper files or MNIST images. Select the first cell, use Insert → Code cell (or + Code) to add a code cell, and move it to the very top using the cell's move-up control. Paste the supplied code below and run it with Shift+Enter. When the file picker appears, upload A1_Student_Package.zip, not the .ipynb file.

import sys

if "google.colab" in sys.modules:
    import io
    import os
    import zipfile
    from pathlib import Path
    from google.colab import files

    folder = Path("/content/A1_Student_Package")
    required = [
        "a1_v8_support.py", "a1_v8_checks.py", "data/mnist_splits.npz",
        "data/MNIST/raw/train-images-idx3-ubyte",
        "data/MNIST/raw/train-labels-idx1-ubyte",
        "data/MNIST/raw/t10k-images-idx3-ubyte",
        "data/MNIST/raw/t10k-labels-idx1-ubyte",
    ]
    if not all((folder / name).is_file() for name in required):
        print("Choose A1_Student_Package.zip in the file picker below.")
        uploaded = files.upload()
        if len(uploaded) != 1:
            raise ValueError("Upload the single A1 student ZIP, then rerun this cell.")
        with zipfile.ZipFile(io.BytesIO(next(iter(uploaded.values())))) as archive:
            for name in required:
                member = "A1_Student_Package/" + name
                destination = folder / name
                destination.parent.mkdir(parents=True, exist_ok=True)
                destination.write_bytes(archive.read(member))
    os.chdir(folder)
    if str(folder) not in sys.path:
        sys.path.insert(0, str(folder))
    print("A1 files ready. Continue with Section 0.")

Run the remaining cells in order. Keep this supplied setup cell in your submitted notebook; it skips the upload outside Colab. The active notebook is your Drive copy. The setup loads only helpers and data, so it does not overwrite your edited notebook.

Colab supplies Python and the libraries used here; you can skip local installation. If a fresh runtime loses its files, rerun this cell and upload the ZIP again. After a restart, rerun the earlier cells to recreate your variables.

Save and download your work

Download the model before leaving the session. Submit the notebook, model and separate written-answer PDF listed in README.md.

References: Colab help, Colab file-upload examples.