Assignment 04: Automatic Differentiation with PyMatch
Learning Goals
- Learn how to read Python code
- Learn about automatic differentiation
- Implement automatic differentiation functionality
- Appreciate that automatic differentiation drives much of the speed behind machine learning research
Grading Walk-Throughs
This assignment will be graded as “Nailed It” / “Not Yet” by a TA. To complete (“Nailed It”) the assignment, you must
- Complete the assignment and submit your work to gradescope.
- Meet with a TA during their mentor session hours.
- Complete the walk-through with all group members. I prefer all partners to be present during the walk-through, but you can each meet with the TA separately if needed.
- Walk the TA through your answers. Do not expect to make corrections during the walk-through.
- The TA will then either
- mark your assignment as 100% on gradescope, or
- inform you that you have some corrections to make.
- If corrections are needed, then you will need to complete them and conduct a new walk-through with a TA.
If you have concerns about the grading walk-through, you can meet with me after you have first met with a TA.
Overview
You must work on this assignment with a partner; please let me know if you want me to help you find a partner.
For this assignment you will extend functionality of the PyMatch library. This is a minimal automatic differentiation library I created for this course.
A few notes to get you started:
- Login to Jupyter Hub
- Open a terminal
- Activate the course environment:
conda activate cs152
- Create a new directory for the assignment (anywhere you’d like, but not inside the current
cs152
directory) - Clone the match repository:
gh repo clone pymatch/pymatch
- Read the library’s readme in its entirety
- Read through the library code, test file, and demo
Tasks
For the assignment, you must:
Answer the pen-and-paper questions on gradescope (you should open it now and read through all questions).
Add functionality for a leaky rectified linear unit.
Add functionality for mean-absolute-error (MAE) loss (aka
L1Loss
).Create a new demo (based on
linear_demo.ipynb
).- name the file
demo_quadratic.ipynb
- the data must be quadratic instead of linear
- use your new leaky ReLU and mean-absolute-error functionality
- hint: you’ll need to change the data, the model, and the loss function
- name the file
(Optional.) Add any other functionality that you find interesting and submit a pull-request!
Examples
Here are a few examples that you might find useful as you’re working on your assignment.
Submitting Your Assignment
You will submit your responses on gradescope. Only one partner should submit. The submitter will add the other partner through the gradescope interface.
Additional details for using gradescope can be found here: