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.
data/ together.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.
.venv.The full VS Code notebook guide shows these controls.
TODOs, then remove the corresponding raise NotImplementedError(...) line. This error is expected until you finish the exercise. Preserve the supplied cells, function names and arguments.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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.