first commit

This commit is contained in:
2023-10-10 09:42:31 +08:00
commit 175bf7b7da
12 changed files with 3102 additions and 0 deletions

12
Lab1/code/1.3.py Normal file
View File

@@ -0,0 +1,12 @@
import torch
x = torch.tensor(1.0, requires_grad=True)
y_1 = x**2
with torch.no_grad():
y_2 = x**3
y3 = y_1 + y_2
y3.backward()
print("梯度(dy_3/dx): ", x.grad.item())