pytorch之打印网络节点

1 输入:

import torch

the_model = torch.load("model.pt")
print (the_model)

params=the_model.state_dict()
len(params)
for i, j in enumerate(params):
  print i, j

2 输出: 

RNNModel(
  (drop): Dropout(p=0.2)
  (encoder): Embedding(33278, 200)
  (rnn): LSTM(200, 200, num_layers=2, dropout=0.2)
  (decoder): Linear(in_features=200, out_features=33278, bias=True)
)

0 encoder.weight
1 rnn.weight_ih_l0
2 rnn.weight_hh_l0
3 rnn.bias_ih_l0
4 rnn.bias_hh_l0
5 rnn.weight_ih_l1
6 rnn.weight_hh_l1
7 rnn.bias_ih_l1
8 rnn.bias_hh_l1
9 decoder.weight
10 decoder.bias

3 当然,使用model.named_parameters()也能打印出网络参数和名称,有兴趣的可以试试啊。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值