torch.nn.modules.linear — PyTorch 1.10.1 documentation
pytorch.org › torch › nnclass LazyLinear (LazyModuleMixin, Linear): r """A :class:`torch.nn.Linear` module where `in_features` is inferred. In this module, the `weight` and `bias` are of :class:`torch.nn.UninitializedParameter` class. They will be initialized after the first call to ``forward`` is done and the module will become a regular :class:`torch.nn.Linear` module.
Linear — PyTorch 1.10.1 documentation
pytorch.org › generated › torchLinear¶ class torch.nn. Linear (in_features, out_features, bias = True, device = None, dtype = None) [source] ¶ Applies a linear transformation to the incoming data: y = x A T + b y = xA^T + b y = x A T + b. This module supports TensorFloat32. Parameters. in_features – size of each input sample. out_features – size of each output sample
pytorch的初始化方式总结 - 知乎
https://zhuanlan.zhihu.com/p/97651850Linear (n_hidden_2, out_dim)) # 迭代循环初始化参数 for m in self. children (): if isinstance (m, nn. Linear): nn. init. constant_ (m. weight, 1) nn. init. constant_ (m. bias,-100) # 也可以判断是否为conv2d,使用相应的初始化方式 elif isinstance (m, nn. Conv2d): nn. init. kaiming_normal_ (m. weight, mode = 'fan_out ...