
正文
pytorch中的Linear Layer(线性层)
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
LINEAR LAYERS
Linear
-
-
Examples:
>>> m = nn.Linear(20, 30)
>>> input = torch.randn(128, 20)
>>> output = m(input)
>>> print(output.size())
torch.Size([128, 30])
查看源码后发现U指的是均匀分布,即weight权重(A的转置)是取自输入尺寸的倒数再开方后的正负值之间的均匀分布,同理可得偏置bias是输出尺寸
的倒数再开方后的正负值之间的均匀分布。
资料参考于官网:https://pytorch.org/docs/stable/nn.html#linear-layers
Linear
-
-
Examples:
>>> m = nn.Linear(20, 30)
>>> input = torch.randn(128, 20)
>>> output = m(input)
>>> print(output.size())
torch.Size([128, 30]) 查看源码后发现U指的是均匀分布,即weight权重(A的转置)是取自输入尺寸的倒数再开方后的正负值之间的均匀分布,同理可得偏置bias是输出尺寸的倒数再开方后的正负值之间的均匀分布。
资料参考于官网:https://pytorch.org/docs/stable/nn.html#linear-layers







