tensor

在PyTorch中,torch.Tensor是存储和变换数据的主要工具。

Tensor与Numpy的多维数组非常相似。

Tensor还提供了GPU计算和自动求梯度等更多功能,这些使Tensor更适合深度学习。

1
2
3
4
5
6
x = torch.empty(5,3)
x = torch.rand(5,3)
x = torch.randn(2,3)
x = torch.zeros(5,3,dtype=long)
x = torch.tensor([5.5,3])
...

torch.nn.Conv2d