官方文档:LINEAR

PyTorch笔记 torch.nn.Linear

注意到这个公式:

PyTorch笔记 torch.nn.Linear

结合代码讲解其中的含义:

PyTorch笔记 torch.nn.Linear

PyTorch笔记 torch.nn.Linear

x的维度:4*2
L的weight的维度:3*2
L的bias的维度:3
y的维度:4*3

根据线性代数的矩阵乘法的知识,可以猜想,是不是 y = x*weight^T + bias(其中,+bias为广播)?

验证一下:

PyTorch笔记 torch.nn.Linear

果然,L.weight是公式中的A,L.bias是公式中的b。

相关文章:

  • 2021-05-26
  • 2022-02-11
  • 2021-05-26
  • 2021-09-04
  • 2021-12-09
  • 2021-05-17
猜你喜欢
  • 2021-07-17
  • 2021-12-28
  • 2021-08-22
  • 2021-12-25
  • 2021-11-06
  • 2022-03-05
  • 2021-04-11
相关资源
相似解决方案