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
>>> 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
>>> 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
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
经验分享 程序员 微信小程序 职场和发展