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

Part 5 (10 points, coding task)

In this part, you are asked to program with PyTorch, NOT NumPy.

Define a deep neural network module (class) named Linear_Model.

It has the following architecture:

  • 2 layers: 1 hidden layer and 1 output layer.

  • No activation function. That is, the connection between two consecutive layers is only an affine transformation.

### WRITE YOUR SOLUTION HERE ###

class Linear_Model(nn.Module):
    def __init__(self, in_features, hidden_features, out_features):
        super().__init__()
        self.in_features = in_features
        self.hidden_features = hidden_features
        self.out_features = out_features
        self.linear0 = nn.Linear(in_features, hidden_features)
        self.linear1 = nn.Linear(hidden_features, out_features)

    def forward(self, x):
        x = self.linear0(x)
        x = self.linear1(x)
        return x

""" END OF THIS PART """