本文簡要介紹python語言中 torch.nn.ParameterDict 的用法。
- 用法:- class torch.nn.ParameterDict(parameters=None)
- parameters(可迭代的,可選的) -(字符串: - Parameter)的映射(字典)或類型為(字符串,- Parameter)的鍵值對的可迭代
- 在字典中保存參數。 - ParameterDict 可以像普通的 Python 字典一樣被索引,但它包含的參數已正確注冊,並且對所有 Module 方法都是可見的。 - ParameterDict是一個排序尊重的字典- 插入順序,以及 
- 在 - update()中,合並的- OrderedDict或另一個- ParameterDict的順序(- update()的參數)。
 - 請注意, - update()與其他無序映射類型(例如,Python 的普通- dict)不會保留合並映射的順序。- 例子: - class MyModule(nn.Module): def __init__(self): super(MyModule, self).__init__() self.params = nn.ParameterDict({ 'left': nn.Parameter(torch.randn(5, 10)), 'right': nn.Parameter(torch.randn(5, 10)) }) def forward(self, x, choice): x = self.params[choice].mm(x) return x
參數:
相關用法
- Python PyTorch ParameterList用法及代碼示例
- Python PyTorch ParagraphAggregator用法及代碼示例
- Python PyTorch ParallelReadConcat用法及代碼示例
- Python PyTorch ParquetDataFrameLoader用法及代碼示例
- Python PyTorch Pareto用法及代碼示例
- Python PyTorch PackageImporter.id用法及代碼示例
- Python PyTorch PackageExporter.register_extern_hook用法及代碼示例
- Python PyTorch PairwiseDistance用法及代碼示例
- Python PyTorch PackageExporter.register_intern_hook用法及代碼示例
- Python PyTorch PackageExporter.close用法及代碼示例
- Python PyTorch PackageExporter.register_mock_hook用法及代碼示例
- Python PyTorch Proxy用法及代碼示例
- Python PyTorch PoissonNLLLoss用法及代碼示例
- Python PyTorch PixelShuffle用法及代碼示例
- Python PyTorch Pipe用法及代碼示例
- Python PyTorch PooledEmbeddingsAllToAll用法及代碼示例
- Python PyTorch Poisson用法及代碼示例
- Python PyTorch Perceptron用法及代碼示例
- Python PyTorch PixelUnshuffle用法及代碼示例
- Python PyTorch PitchShift用法及代碼示例
- Python PyTorch PooledEmbeddingsReduceScatter用法及代碼示例
- Python PyTorch PReLU用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.nn.ParameterDict。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
