Table of Contents
Shortcuts

# LazyLinear

class torch.nn.LazyLinear(out_features, bias=True, device=None, dtype=None)

  A `torch.nn.Linear` module where in_features is inferred.

  In this module, the weight and bias are of `torch.nn.UninitializedParameter` class. They will be initialized after the first call to `forward` is done and the module will become a regular `torch.nn.Linear` module. The `in_features` argument of the `Linear` is inferred from the `input.shape[-1]`.

  Check the `torch.nn.modules.lazy.LazyModuleMixin` for further documentation on lazy modules and their limitations.

  Parameters:

    - out_features (int) – size of each output sample

    - bias (UninitializedParameter) – If set to `False`, the layer will not learn an additive bias. Default: `True`

  Variables:

    - weight (torch.nn.parameter.UninitializedParameter) – the learnable weights of the module of shape (out_features,in_features)(\text{out\_features}, \text{in\_features})(out_features,in_features). The values are initialized from U(−k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k})U(−k
      ​,k
      ​), where k=1 in_features k = \frac{1}{\text{in\_features}}k=in_features 1​

    - bias (torch.nn.parameter.UninitializedParameter) – the learnable bias of the module of shape (out_features)(\text{out\_features})(out_features). If `bias` is `True`, the values are initialized from U(−k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k})U(−k
      ​,k
      ​) where k=1 in_features k = \frac{1}{\text{in\_features}}k=in_features 1​

  cls_to_become

    alias of `Linear`

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.