2025 USA-NA-AIO Round 1, Problem 2, Part 1

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.eig to 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

\mathbf{y} = \mathbf{W} \mathbf{x} + \mathbf{b} ,

where

  • \mathbf{W} \in \Bbb R^{M \times N}.

  • \mathbf{b} \in \Bbb R^{M}.

Now, let us study a small-sized problem.

Let

\mathbf{W} = \begin{bmatrix} 2 & -3 & 1 & 3 & -2 \\ 0 & 1 & 2 & 5 & -1 \\ 7 & -1 & -3 & 7 & 0 \end{bmatrix}

and

\mathbf{b} = \begin{bmatrix} 1 \\ 0 \\ -1 \end{bmatrix}

and

\mathbf{x} = \begin{bmatrix} 1 \\ 2 \\ -3 \\ 1 \\ -2 \end{bmatrix}

Answer the following questions:

  1. What is the value of N?

  2. What is the value of M?

  3. What is the value of \mathbf{y}.

Questions 1 and 2 do not require reasoning. Question 3 requires reasoning.

\color{green}{\text{### WRITE YOUR SOLUTION HERE ###}}

  1. N = 5.

  2. M = 3.

  3. We have

\begin{align*} \mathbf{y} & = \mathbf{W} \mathbf{x} + \mathbf{b} \\ & = \begin{bmatrix} 2 & -3 & 1 & 3 & -2 \\ 0 & 1 & 2 & 5 & -1 \\ 7 & -1 & -3 & 7 & 0 \end{bmatrix} \begin{bmatrix} 1 \\ 2 \\ -3 \\ 1 \\ -2 \end{bmatrix} + \begin{bmatrix} 1 \\ 0 \\ -1 \end{bmatrix} \\ & = \begin{bmatrix} 2 \cdot 1 + (-3) \cdot 2 + 1 \cdot (-3) | 3 \cdot 1 + (-2) \cdot (-2) + 1 \\ 0 \cdot 1 + 1 \cdot 2 + 2 \cdot (-3) + 5 \cdot 1 + (-1) \cdot (-2) + 0 \\ 7 \cdot 1 (-1) \cdot 2 + (-3) \cdot (-3) + 7 \cdot 1 + 0 \cdot (-2) + (-1) \end{bmatrix} \\ & = \boxed{\begin{bmatrix} 1 \\ 3 \\ 20 \end{bmatrix} }. \end{align*}

\color{red}{\text{""" END OF THIS PART """}}