torch.autograd

PHOTO EMBED

Sat Jul 16 2022 01:02:36 GMT+0000 (Coordinated Universal Time)

Saved by @linzao

z = torch.matmul(x, w)+b
print(z.requires_grad)

with torch.no_grad():
    z = torch.matmul(x, w)+b
print(z.requires_grad)

z = torch.matmul(x, w)+b
z_det = z.detach()
print(z_det.requires_grad)
content_copyCOPY

https://pytorch.org/tutorials/beginner/basics/autogradqs_tutorial.html