我已经训练过我的模型在火把。现在,我想提取一个特定的参数张量的名称(不是所有张量)。我怎么能这么做?
print(myModel.parameters)
产出:
<bound method Module.parameters of ANN(
(fc1): Linear(in_features=2, out_features=4, bias=True)
(fc2): Linear(in_features=4, out_features=1, bias=True)
)>
例如,我只想得到fc1.wright和fc1.偏向。
发布于 2022-08-19 12:37:10
您可以直接使用点表示法访问子模块,而parameters
在不提供键的情况下在所有张量上返回迭代器:
>>> myModel.fc1.weight
>>> myModel.fc1.bias
https://stackoverflow.com/questions/73416801
复制相似问题