Problem 2 (100 points)
This problem is about the basics of neural network.
Before starting this problem, make sure to run the following code first without change:
""" DO NOT CHANGE """
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.optim as optim
torch.manual_seed(2025)
\color{red}{\text{WARNING !!!}}
-
Beyond importing libraries/modules/classes/functions in the preceeding cell, you are NOT allowed to import anything else for the following purposes:
-
As a part of your final solution. For instance, if a problem asks you to build a model without using sklearn but you use it, then you will not earn points.
-
Temporarily import something to assist you to get a solution. For instance, if a problem asks you to manually compute eigenvalues but you temporarily use
np.linalg.eigto get an answer and then delete your code, then you violate the rule.
Rule of thumb: Each part has its particular purpose to intentionally test you something. Do not attempt to find a shortcut to circumvent the rule.
-
-
All coding tasks shall run on CPUs, not GPUs.
Part 1 (5 points, non-coding task)
The high level idea of affine transformation in math is that for each column vector \mathbf{x} \in \Bbb R^N, an affine transformation maps it to another column vector \mathbf{y} \in \Bbb R^M via
where
-
\mathbf{W} \in \Bbb R^{M \times N}.
-
\mathbf{b} \in \Bbb R^{M}.
Now, let us study a small-sized problem.
Let
and
and
Answer the following questions:
-
What is the value of N?
-
What is the value of M?
-
What is the value of \mathbf{y}.
Questions 1 and 2 do not require reasoning. Question 3 requires reasoning.