PyTorch 2 · Autograd and models

Skip gradient tracking

Save memory and time when predicting.

with torch.no_grad():
    preds = model(x)

Official PyTorch 2 documentation

More autograd and models commands

All autograd and models commands · PyTorch 2 cheatsheet

Was this page helpful?