Premium problem76. Inference Without Gradient Tracking

Easy Locked

Build Linear(4, 2) after torch.manual_seed(seed), then run x through it for inference: in evaluation mode and without recording a graph.

Return the tuple (output, tracks_gradient) where tracks_gradient is the output's requires_grad as a plain bool. A correct answer has it False.

eval() and no_grad() are different tools: the first changes how layers like Dropout and BatchNorm behave, the second stops autograd building a graph. This needs both.

Input

x =
tensor([[1., 1., 1., 1.],
        [1., 1., 1., 1.]])
seed = 0

Output

(tensor([[-0.5594,  0.4603],
        [-0.5594,  0.4603]]), False)

Premium problem

This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.

Implement solve(...)