Files
Brukino_AntiPaSTO_Appetizer/test_grad.py
T
2026-04-10 11:12:45 +08:00

6 lines
118 B
Python

import torch
x = torch.tensor([1.0, 2.0, 4.0, 7.0])
with torch.no_grad():
dx = torch.gradient(x)[0]
print(dx)