pytorch中输出模型参数名和梯度的一些操作

1. 输出参数名字的一些操作

输出需要梯度的参数的名字

1
2
3
for n,p in self.lm_head.named_parameters():
if p.requires_grad == True:
print(n)
Error: API rate limit exceeded for 35.174.118.81. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)