How to look at the parameters of a pytorch model?

时间:2019-01-18 18:57:27

标签: machine-learning neural-network pytorch openai-gym

I have a simple pytorch neural net that I copied from openai, and I modified it to some extent (mostly the input).

When I run my code, the output of the network remains the same on every episode, as if no training occurs.

I want to see if any training happens, or if some other reason causes the results to be the same.

How can I make sure any movement happens to the weights?

Thanks

1 个答案:

答案 0 :(得分:3)

取决于您的工作,但是最简单的方法是检查模型的权重。

您可以使用以下代码执行此操作(并与上一次迭代的结果进行比较):

for parameter in model.parameters():
    print(parameter.data)

如果权重在变化,则说明神经网络正在优化(这不一定意味着它会学到特别有用的东西)。