Pytorch基本操作
数值运算
1.张量对象已覆盖使用Python数值运算,并且运算符与普通运算符一样。张量—标量操作就是一种。
x=torch.ones(3,2)#新建一个3*2的张量
x
tensor([[1., 1.],
[1., 1.],
[1., 1.]])
y=torch.ones(3,2)+2
y
tensor([[3., 3.],
[3., 3.],
[3., 3.]])
z= torch.ones(2,1)
z
tensor([[1.],
原创
2021-06-27 09:49:49 ·
122 阅读 ·
0 评论