【Pytorch】查看模型结构、参数和各种属性

【Pytorch】查看模型结构、参数和各种属性,第1张

【Pytorch】查看模型结构、参数和各种属性
  • 一、torchsummary模块
  • 二、torchstat模块
  • 三、model.children()和model.modules()
  • 四、model.parameters()和model.named_parameters()
  • 五、model.state_dict()
  • 六、m.__class__.__name__

一、torchsummary模块 二、torchstat模块 三、model.children()和model.modules() 四、model.parameters()和model.named_parameters() 五、model.state_dict() 六、m.class.name

获取module的classname。

import torch
conv = torch.nn.Conv2d(1,8,3,1)
bn = torch.nn.BatchNorm2d(8)
l = [conv,bn]
for item in l:
    print(item.__class__.__name__)
# 输出结果:
# Conv2d
# BatchNorm2d

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/727255.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-04-26
下一篇2022-04-26

发表评论

登录后才能评论

评论列表(0条)

    保存