本文簡要介紹python語言中 torch.nn.Linear 的用法。
- 用法:- class torch.nn.Linear(in_features, out_features, bias=True, device=None, dtype=None)
- in_features-每個輸入樣本的大小 
- out_features-每個輸出樣本的大小 
- bias-如果設置為 - False,該層將不會學習附加偏差。默認值:- True
 
- ~Linear.weight(torch.Tensor) -形狀為 的模塊的可學習權重。這些值從 初始化,其中 
- ~Linear.bias-形狀為 的模塊的可學習偏差。如果 - bias是- True,則值從 初始化,其中
 
- 對傳入數據應用線性變換: - 該模塊支持 TensorFloat32。 - 形狀:
- 輸入: 其中 表示任意數量的維度,包括 none 和 。 
- 輸出:,其中除了最後一個維度之外的所有維度都與輸入和 的形狀相同。 
 
 - 例子:- >>> m = nn.Linear(20, 30) >>> input = torch.randn(128, 20) >>> output = m(input) >>> print(output.size()) torch.Size([128, 30])
參數:
變量:
相關用法
- Python PyTorch LinearLR用法及代碼示例
- Python PyTorch LinearReLU用法及代碼示例
- Python PyTorch LineReader用法及代碼示例
- Python PyTorch LazyModuleMixin用法及代碼示例
- Python PyTorch LKJCholesky用法及代碼示例
- Python PyTorch L1Loss用法及代碼示例
- Python PyTorch LPPool2d用法及代碼示例
- Python PyTorch LeakyReLU用法及代碼示例
- Python PyTorch LogSigmoid用法及代碼示例
- Python PyTorch LowRankMixtureCrossNet用法及代碼示例
- Python PyTorch LayerNorm用法及代碼示例
- Python PyTorch LogNormal用法及代碼示例
- Python PyTorch LambdaLR用法及代碼示例
- Python PyTorch LocalResponseNorm用法及代碼示例
- Python PyTorch LSTM用法及代碼示例
- Python PyTorch LowRankMultivariateNormal用法及代碼示例
- Python torchrec.modules.crossnet.LowRankCrossNet用法及代碼示例
- Python PyTorch LogSoftmax用法及代碼示例
- Python PyTorch LSTMCell用法及代碼示例
- Python PyTorch LocalElasticAgent用法及代碼示例
- Python PyTorch LPPool1d用法及代碼示例
- Python PyTorch Laplace用法及代碼示例
- Python PyTorch LazyModuleExtensionMixin.apply用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.nn.Linear。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
