FunctionRacerProblemsRace

A Tiny Network

HardPyTorchPython

Train a small network and return how well it ends up fitting. In this order: call torch.manual_seed(seed); build nn.Sequential(nn.Linear(d, 4), nn.Tanh(), nn.Linear(4, 1)), where d is the number of columns of X; take steps steps of torch.optim.SGD with learning rate lr on the mean squared error between the outputs of the network, one per row of X, and y. Then compute that loss once more, and return it.

Example 1

X [[0.0],[1.0],[2.0]]
y [0.0,1.0,2.0]
seed 0
lr 0.1
steps 5
returns 0.07231349498033524

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More PyTorch problems