Learn practical skills, build real-world projects, and advance your career

基础

import torch
t1 = torch.tensor(4.0)
t1
tensor(4.)
t2 = torch.tensor([[1,2],[3.,5.1]])
t2
tensor([[1.0000, 2.0000],
        [3.0000, 5.1000]])
x = torch.tensor(3.)
w = torch.tensor(4., requires_grad=True)
b = torch.tensor(5., requires_grad=True)
y = w * x + b
y
tensor(17., grad_fn=<AddBackward0>)