1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| x =torch.empty(3,4) torch.zeros(2,3) torch.ones(2,3) torch.manual_seed(1998) torch.rand(4,4) torch.rand_like(x) torch.tensro([3,4]) torch.one((2,3),dtype=torch.int16)
torch.zeros(2,2)+1 torch.ones(2,2)*3 torch.rand(3,4)**4
torch.rand(3,4)*(torch.rand(3,4)*2)
torch.abs(a) torch.ceil(a) torch.floor(a) torch.clamp(a,0.5,0.5) torch.sin(a) torch.asin(a) torch.bitwise_and(a,x)
torch.max() torch.mean() torch.std() torch.prod()
v1 = torch.tensor([1., 0., 0.]) # x unit vector v2 = torch.tensor([0., 1., 0.]) # y unit vector torch.cross(v2,v1) torch.matmul(a,x) torch.mv(a,v2) torch.svd(x)
x =torch.empty(3,4) torch.zeros(2,3) torch.ones(2,3) torch.manual_seed(1998) torch.rand(4,4) torch.rand_like(x) torch.tensro([3,4]) torch.one((2,3),dtype=torch.int16)
torch.zeros(2,2)+1 torch.ones(2,2)*3 torch.rand(3,4)**4
torch.rand(3,4)*(torch.rand(3,4)*2)
torch.abs(a) torch.ceil(a) torch.floor(a) torch.clamp(a,0.5,0.5) torch.sin(a) torch.asin(a) torch.bitwise_and(a,x)
torch.max() torch.mean() torch.std() torch.prod()
v1 = torch.tensor([1., 0., 0.]) # x unit vector v2 = torch.tensor([0., 1., 0.]) # y unit vector torch.cross(v2,v1) torch.matmul(a,x) torch.mv(a,v2) torch.svd(x)
x=torch.rand(3,4,requires_grad=True) y=x+2 y.sum().backward() plt.plot(x.detach(),y.detach()) with torch.no_grad(): y=x+2
|