PyTorch: What's the difference between state_dict and parameters()?

后端 未结 2 1899
被撕碎了的回忆
被撕碎了的回忆 2021-02-13 20:34

In order to access a model\'s parameters in pytorch, I saw two methods:

using state_dict and using parameters()

I wonder what\'s the difference, or if one is good

2条回答
  •  情深已故
    2021-02-13 20:51

    Besides the differences in @kHarshit 's answer, the attribute requires_grad of trainable tensors in net.parameters() is True, while False in net.state_dict()

提交回复
热议问题