I’m unsure how to reproduce the issue, as I’m getting valid gradients in the input:
model = L2Net(10, 1)
x = torch.randn(1, 784, requires_grad=True)
out = model(x)
out.mean().backward()
print(x.grad)
> tensor([[-9.4862e-04,  3.0799e-04,  6.3704e-04, -1.2979e-05, -5.3003e-04,
            9.0936e-06, -7.5076e-04, -7.7078e-04, -5.5273e-04,  8.0073e-04,
            4.7446e-04,  9.0180e-04, -4.5098e-04,  1.5162e-04,  7.3597e-04,
            ...