Closed moka1994 closed 3 years ago
n_trainable_params, n_nontrainable_params = 0, 0
for p in model.parameters():
n_params = torch.prod(torch.tensor(p.shape))
if p.requires_grad:
n_trainable_params += n_params
else:
n_nontrainable_params += n_params
print('n_trainable_params: {0}, n_nontrainable_params: {1}'.format(n_trainable_params, n_nontrainable_params))
您好,谢谢回信。依照您回复的代码已经解决了我的问题,十分感谢。
您好,请问如果想知道BERT的预训练模型的大小,应该怎样查看呢?