mirror of
https://github.com/yunjey/pytorch-tutorial.git
synced 2025-07-10 13:49:37 +08:00
Merge pull request #128 from timctho/master
Fix requires_grad=True needs float tensor
This commit is contained in:
@ -23,9 +23,9 @@ import torchvision.transforms as transforms
|
|||||||
# ================================================================== #
|
# ================================================================== #
|
||||||
|
|
||||||
# Create tensors.
|
# Create tensors.
|
||||||
x = torch.tensor(1, requires_grad=True)
|
x = torch.tensor(1., requires_grad=True)
|
||||||
w = torch.tensor(2, requires_grad=True)
|
w = torch.tensor(2., requires_grad=True)
|
||||||
b = torch.tensor(3, requires_grad=True)
|
b = torch.tensor(3., requires_grad=True)
|
||||||
|
|
||||||
# Build a computational graph.
|
# Build a computational graph.
|
||||||
y = w * x + b # y = 2 * x + 3
|
y = w * x + b # y = 2 * x + 3
|
||||||
|
Reference in New Issue
Block a user