1. Different t.Tensor and the t.tensor
t.Tensor (size) can create a form for the size of the direct tensor
t.tensor () requires t.tensor ([1, 2]) to create what is regardless of the input type, t.tensor will copy data, do not share memory
2. resize () and view () different
a resize () can be modified tensor size, and view () can adjust the shape
3. a[0:1, :2].size()=torch.Size([1, 2])
a[0, :2].size()=torch.Size([2])
4. Parametersdim
Suppose that the shape of the input (m, n, k)
-
- If you specify dim = 0, is the shape of the output (1, n, k) or (n, k)
- If the specified dim = 1, is the shape of the output (m, 1, k) or (m, k)
- If you specify dim = 2, it is the shape of the output (m, n, 1) or (m, n)
Is there a "1", depending on the size of the parameters keepdim
, keepdim=True
will remain dimension 1
.
Not all functions are in line with changes in the way this shapes, such ascumsum
5. torch.mm () matrix multiplication
torch.mul () bit corresponding to a matrix multiplication