最多支持两维,
我准备用这个代替1*1的卷积核
import torch
x = torch.randn(128, 20) # 输入的维度是(128,20)
m = torch.nn.Linear(20, 50) # 20,30是指维度
output = m(x)
print('m.weight.shape: ', m.weight.shape)
print('m.bias.shape:', m.bias.shape)
print('output.shape:', output.shape)
# ans = torch.mm(input,torch.t(m.weight))+m.bias 等价于下面的
ans = torch.mm(x, m.weight.t()) + m.bias
print('ans.shape:', ans.shape)
print(torch.equal(ans, output))