Skip to content

Commit 2bfebb0

Browse files
committed
Fix requires_grad=True needs float tensor
1 parent 9219526 commit 2bfebb0

File tree

1 file changed

+3
-3
lines changed
  • tutorials/01-basics/pytorch_basics

1 file changed

+3
-3
lines changed

tutorials/01-basics/pytorch_basics/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
# ================================================================== #
2424

2525
# Create tensors.
26-
x = torch.tensor(1, requires_grad=True)
27-
w = torch.tensor(2, requires_grad=True)
28-
b = torch.tensor(3, requires_grad=True)
26+
x = torch.tensor(1., requires_grad=True)
27+
w = torch.tensor(2., requires_grad=True)
28+
b = torch.tensor(3., requires_grad=True)
2929

3030
# Build a computational graph.
3131
y = w * x + b # y = 2 * x + 3

0 commit comments

Comments
 (0)