Last modified: 2026-03-07 18:07
Updates
- 2026-03-02 12:00: Fixed \(u\) vs. \(v\) in problem 1 and gradient definition in problem 4.
- 2026-03-03 12:00: 4B is asking for the maximum possible value, not the value generally.
Status: RELEASED.
Due date: Wed Mar 4, 2026 by end of day (11:59 pm ET) in Medford, MA
Turn-in links:
- PDF/Image report turned in to: https://www.gradescope.com/courses/1220989/assignments/7743123
- Complete your reflection here: https://forms.gle/9tHp4zCpHcFAMt2Z9
Overview
This is a purely written homework, no coding is required. You only have to turn in a PDF of your solutions. You are welcome to either typeset or hand-write your solution. You can scan handwritten solutions, or Gradescope has a mobile app that makes submitting via taking pictures on your phone streamlined.
Evaluation Rubric
The worth of each problem is
- 97% written solutions
- 3% reflection
See the submission portal on Gradescope for the point values of each problem/subproblem.
Files to Turn In:
PDF report (or images via the Gradescope app):
- This document will be manually graded.
- Should have each subproblem marked via the in-browser Gradescope annotation tool)
Problem 1: Parameters and Structure
Problem 1a: Drawing a Neural Network
Consider an MLP that maps input features \(x = [x_1, x_2]\) to a scalar prediction \(y \in \mathbb{R}\). The MLP contains a single fully-connected hidden layer with 3 hidden units.
The output layer uses an identity activation function, so \(v = f(u) = u\), where \(u\) is the input to the activation function and \(v\) is the output of that layer. All hidden units use a ReLU activation function: \(v = f(u) = \text{max}(u,0)\). All hidden units and the output layer have a bias feature.
Draw a labeled diagram of the MLP described above. You do not need to represent activation functions, but your diagram should include biases, which can be labeled such that the bias term of \(h_1\) is labeled \(b_{h1}\). Nodes should represent inputs, outputs, and hidden units while edges represent weights in the neural network. Label the input nodes \(x_1\) and \(x_2\), the output node as \(y\), and hidden units as \(h_1, h_2, ...\) etc. Weights should then be labeled such that the weight going from \(x_1\) to \(h_1\) is labeled \(w_{x1h1}\).
Problem 1b: Neural Network Dimensions
Imagine that you want to create a neural network for classifying MNIST images, which consist of 28x28 grayscale images of handwritten digits. This is a multiclass classification task with 10 classes, the digits 0-9. You decide to create the following neural network architecture:
- Input Layer (\(X\)): The image flattened into a 1D vector.
- Hidden Layer 1 (\(h_1\)): fully connected 128 neurons with a ReLU activation function.
- Hidden Layer 2 (\(h_2\)): fully connected 64 neurons with a ReLU activation function.
- Output Layer: neurons with a Softmax activation function to create a 1-hot encoding of the predicted class.
Note that this is a different network with different dimensions than the network in 1a.
Fill in all empty table entries below (denoted by \(\dots\)) to describe the shape and number of parameters in each layer in the network.
| Component | Description | Shape | Total Parameters |
|---|---|---|---|
| Input \(X\) | Flattened Image Vector | \(\dots \times 1\) | NA |
| \(w_1\) | Input to \(h_1\) weights | \(\dots \times \dots\) | \(\dots\) |
| \(b_1\) | \(h_1\) bias | \(\dots \times 1\) | \(\dots\) |
| \(w_2\) | \(h_1\) to \(h_2\) weights | \(64 \times 128\) | \(8,192\) |
| \(b_2\) | \(h_2\) bias | \(\dots \times 1\) | \(64\) |
| \(w_3\) | \(h_2\) to Output weights | \(\dots \times \dots\) | \(\dots\) |
| \(b_3\) | Output bias | \(\dots \times 1\) | \(\dots\) |
| Total | Entire Network | NA | \(\dots\) |
Problem 2: Recreating a Hat
A friend of yours, a CS student who has not taken CS135, comes to you one day very excited about their "new transformative AI" that they're calling HatNet. When you ask what they mean, they show you a plot of a neural network's output as it's single input varies:
Figure 2: A hat shaped neural network output.
They excitedly state that this AI they made has clearly learned what a hat is without any outside information. You look at their code and find a simple neural network with a single input, a single output using the identity activation function, and one hidden layer consisting of 4 nodes using ReLU activation functions. You also notice in your friend's code that they have initialized the network weights and biases to random integers between -5 and 5 instead of a more typical initialization scheme. They have not performed any training so all weights and biases are still at their initialized values.
Assuming all other weights are \(1\) and all other biases are \(0\), what are values of the \(4\) weights from the hidden layer to the output layer and \(4\) biases of the hidden layer that could cause the neural network to produce this shape? Recall that the ReLU activation function is \(f(x) = \max(0, x)\).
Problem 3: Forward and Backward for Neural Networks
Consider the MLP diagrammed below that maps input features \(x = [x_1, x_2]\) to a scalar prediction \(v_3 \in \mathbb{R}\).
This MLP has several components:
- First layer activation: ReLU : \(v = f(u) = \text{max}(u,0)\).
- Second (output) layer activation: identity, so \(v = u\).
- Final loss function \(E\) is squared error: \(E(y, v_3) = (y - v_3)^2\)
Problem 3a
Consider the neural net with provided inputs exactly as in this diagram
Figure 2a: Neural net diagram for FORWARD pass.
Complete the forward pass in this network. Fill in the numerical value of each variable in the table below. Be sure to show your work.
| Node | Value |
|---|---|
| \(u_1\) | _____ |
| \(v_1\) | _____ |
| \(u_2\) | _____ |
| \(v_2\) | _____ |
| \(u_3\) | _____ |
| \(E\) | _____ |
Problem 3b
Consider the neural net with provided inputs exactly as in this diagram
Figure 2b: Neural net for BACKWARD pass, with forward pass values already filled in.
First, recall the derivatives used as building blocks below
Where \(f'(u)\) is the ReLU activation function \(f(u) = \max(u, 0)\). Second, recall this simplified pseudocode for backprop:
Complete the backward pass in this network, using the forward pass values already provided. Provide numerical values for each quantity in the table below. Be sure to show your work.
| Node | Value |
|---|---|
| \(\frac{d E}{d u_1}\) | _____ |
| \(\frac{d E}{d v_1}\) | _____ |
| \(\frac{d E}{d u_2}\) | _____ |
| \(\frac{d E}{d v_2}\) | _____ |
| \(\frac{d E}{d u_3}\) | _____ |
Problem 4: Sigmoids
Recall that the sigmoid function is defined as:
and its derivative is
Problem 4a
What is the maximum value of the derivative of a sigmoid? Hint: let \(m = \sigma(u)\) so that the derivative becomes \(m(1-m)\), and recall that the vertex of a parabola of the form \(y= ax^2 + bx + c\) is \(-\frac{b}{2a}\). Remember to plug back into the sigmoid function. Alternatively, you are also welcome to plot the derivative and find the max visually, just note in your answer that you took that approach.
Problem 4b:
Consider a "deep" linear chain of nodes with 4 layers where each layer has only one unit. The output of this network would this be:
and thus if we're using mean squared error (\(L = \frac{1}{2} (y - \hat{y})^2\)) the partial derivative of loss with respect to \(w_1\) would be:
where \(v_i\) is the output of the previous layer's activate function.
Assuming all bias parameters and weights are initialized to \(1\), given your answer to 4a, a particular input, output of the network, and true label \(x_1, \hat{y}_1, y_1\) what is the maxumum possible value \(\frac{\partial L}{\partial w_1}\) in terms of \(x_1\), \(\hat{y}_1\), and \(y_1\)?
Problem 4c:
Considering your answer from 4b, why are multiple layers of sigmoid activation functions typically not recommended for deep neural networks?
Problem 5: ReLU
The derivative of the ReLU function is defined as:
Sidenote: this function is not differentiable at 0, but we define the derivative at 0 to be 0.
Consider a single neuron \(h\) with a ReLU activation function \(f(u) = max(u, 0)\). Suppose the weights \(w\) and bias \(b\) are initialized such that for the entire training set \(X\), the pre-activation \(u^T x + b\) from the previous layer is always less than or equal to 0.
Problem 5a:
What would the output of the node be for any given input in the training set? What would its local gradient \(\frac{\partial f}{\partial u}\) be?
Problem 5b:
What would happen to the node's weight updates during training? How would this affect the gradient value for layers positioned earlier in the chain of nodes in the neural network? Is there a way out of this situation?
Problem 6: Training
Below is a contour plot of loss as 2 model parameters (\(w1\) and \(w2\)) vary during two different runs of stochastic gradient descent (SGD), which are labeled as Approach 1 and Approach 2. The runs were performed on computers with different amounts of RAM, due to memory constraints a different batch size had to be used for each run. Lower loss is represented by lighter colors. Both models start at the same point in the upper right of the figure.
Figure 6: Contour plot of loss as 2 model parameters vary during SGD for 2 different runs of the same model. The only difference between the two runs was the batch size.
Problem 6a:
The only difference between the two runs is the batch size used during SGD. Which approach probably used a smaller batch size, and then which probably used a larger batch size? Justify your answer.
Problem 6b:
Both approaches appear to find the minimum loss eventually. If we kept performing SGD iterations, which approach is more likely to "jitter" around the minimum? Why?
Problem 6c:
Suppose that the batch sizes for both approach were fixed. How could you alter the learning rate for each approach to make it look more like the other approach on this plot? Justify your answer.
Problem 6d:
Describe the problems that can arise from using too small of a batch size, and the problems that can arise from too large of a batch size.