LazyLinear
- classtorch.nn.LazyLinear(out_features, bias=True, device=None, dtype=None)[源代码]
-
一个
torch.nn.Linear
模块,其中 in_features 是通过推断得出的。在此模块中,weight 和 bias 是未初始化的参数。在第一次调用
forward
方法后它们将被初始化,并且该模块将成为一个常规的torch.nn.Linear
模块。Linear
的in_features
参数会根据input.shape[-1]
自动推断出来。查阅
torch.nn.modules.lazy.LazyModuleMixin
以了解更多关于延迟模块及其限制的文档。- 参数
-
-
out_features (int) – 输出样本的尺寸
-
bias (UninitializedParameter) – 如果设置为
False
,层将不会学习加性偏置。默认值:True
-
- 变量
-
-
weight (torch.nn.parameter.UninitializedParameter) – 模块的可学习权重,形状为$(\text{out\_features}, \text{in\_features})$。这些值从分布$\mathcal{U}(-\sqrt{k}, \sqrt{k})$初始化,其中$k = \frac{1}{\text{in\_features}}$
-
bias (torch.nn.parameter.UninitializedParameter) – 模块的可学习偏置,形状为$(\text{out\_features})$。如果
bias
为True
,则从分布$\mathcal{U}(-\sqrt{k}, \sqrt{k})$ 初始化偏置值,其中 $k = \frac{1}{\text{in\_features}}$
-
- cls_to_become
-
别名:
Linear