finished chapter 5

This commit is contained in:
Joseph Hopfmüller
2022-10-17 00:21:56 +02:00
parent e3b6c8b90c
commit 34b6999e39
5 changed files with 113 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import torch
x = torch.tensor(1.0)
y = torch.tensor(2.0)
w = torch.tensor(1.0, requires_grad=True)
#forward path and compute loss
y_hat = w*x
loss = (y_hat-y)**2
print(loss)
#backward path
loss.backward()
print(w.grad)
### update weights
### next forward and backwards