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

Part 4 (5 points, coding task)

Do the following tasks in this part.

  1. Construct an object in the class My_Linear_Numpy called linear_model_np.

  2. Set in_features = 3 and out_features = 5.

  3. Create multiple X with the following different shapes, but common numpy random seed number 2025 and the same standard normal distribution.

    • (in_features,)

    • (10,in_features)

    • (10,20,in_features)

    • (10,20,30,in_features)

    After generating X, reset the numpy random seed number to its default value.

  4. We call our constructed function with each of the above X as the input. Print the shape of each output.

### WRITE YOUR SOLUTION HERE ###

in_features = 3
out_features = 5

linear_model_np = My_Linear_NumPy(in_features, out_features)

np.random.seed(2025)

X_list = [np.random.randn(in_features), np.random.randn(10,in_features), np.random.randn(10,20,in_features), np.random.randn(10,20,30,in_features)]

np.random.seed()

for X in X_list:
    print(linear_model_np.forward(X).shape)

""" END OF THIS PART """