=', c, '\n', d, '\n', e, '\n', f)
输出为
c, d, e, f= tensor([[0.8616, 0.8815, 0.5835],
[1.3956,...,下面以一个具体的例子进行讲解
a = torch.rand(4, 784)
# 物理意义为4张图片,全部打平为28*28的数据
# 在图片处理中经常需要使用降维操作,本例考虑将[4, 784]降维成[...32, 64)
print(torch.mm(a, b).shape)
输出
RuntimeError: matrices expected, got 4D, 4D tensors at .....32, 64)
print(torch.matmul(a, b).shape)
输出
torch.Size([4, 3, 64, 64])
这里注意,四维计算时前两个维度和后两个维度分别进行计算,因此...)
输出会报错
RuntimeError: The size of tensor a (3) must match the size of tensor b (4) at non-singleton dimension