Tensor常见的几种形式
Scalar
import torch
from torch import tensor
# Scalar通常是一个数值
x=tensor(42.)
print(x)
Vector
from torch import tensor
v=tensor([1.5,-0.5,3.0])
print(v)
print(v.dim())
print(v.size())
Matrix
from torch import tensor
M=tensor([[1.,2.],[3.,4.]])
print(M)
M.matmul(M)#M*M 矩阵乘法
print(M.matmul(M))
rs=tensor([1.,0.]).matmul(M)
print(rs)