在用pdb debug的时候,有时候需要看一下特定layer的权重以及相应的梯度信息,如何查看呢?

1. 首先把你的模型打印出来,像这样

pytorch查看模型weight与grad

2. 然后观察到model下面有module的key,module下面有features的key, features下面有(0)的key,这样就可以直接打印出weight了,在pdb debug界面输入p model.module.features[0].weight,就可以看到weight,输入 p model.module.features[0].weight.grad就可以查看梯度信息

pytorch查看模型weight与grad

pytorch查看模型weight与grad

 

相关文章:

  • 2021-08-28
  • 2021-04-06
  • 2022-01-27
  • 2022-12-23
  • 2021-09-25
  • 2021-09-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案