美文网首页
2020-11-03

2020-11-03

作者: 周周周__ | 来源:发表于2020-11-03 14:39 被阅读0次
'''
将nn神经网络层链接起来
1:Sequential
    1)、起名字。
    2)、列表。
    3)、有序字典
2:module_list
 
'''
import torch.nn as nn
from collections import OrderedDict
net1 = nn.Sequential()  # 给神经网络层起名字
net1.add_module('conv', nn.Conv2d(3, 3, 3))
net1.add_module('batchnorm', nn.BatchNorm2d(3))
net1.add_module('activation_layer', nn.ReLU())

print(net1)
print(net1.conv)
net2 = nn.Sequential(
    nn.Conv2d(3, 3, 3), nn.BatchNorm2d(3), nn.ReLU()
)
print(net2)
print(net2[0])

net3 = nn.Sequential(
    OrderedDict([('conv', nn.Conv2d(3, 3, 3)),
                 ('batchnorm', nn.BatchNorm2d(3)),
                 ('activation_layer', nn.ReLU()),
                 ])
)
print(net3)


class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.module_list = nn.ModuleList(
            [
                nn.Conv2d(3, 3, 3),
                nn.ReLU()
            ])

相关文章

  • 周二 2020-11-03 23:45 - 06:50 阴 09

    2020-11-03 月总结的一天,顺便开个会周二 2020-11-03 23:45 - 06:50 阴 09h0...

  • RefrigeratorTool

    Effective Date:2020-11-03* RefrigeratorTool(And "we", "ou...

  • 2020-11-03

    Flutter 学习打卡 2020-11-03 02 1. 快速创建 Widget stle ------> 快...

  • 2020-11-03

    【318号】2020-11-03点赞列表 http://www.jianshu.com/p/5d101da93cc...

  • 男童幼儿园坠楼事件感想:设计思维的视角

    2020-11-03看到央视网的官方微信号上发布了消息:https://mp.weixin.qq.com/s/uF...

  • 2020-12-03

    2020-11-03 # 最近git clone项目一直报这个错。 * 于是乎为了解决这个问题我找遍了全网,终于解...

  • 2020-12-05

    2020-11-03 # 最近git clone项目一直报这个错。 * 于是乎为了解决这个问题我找遍了全网,终于解...

  • 2020-12-07

    2020-11-03 # 最近git clone项目一直报这个错。 * 于是乎为了解决这个问题我找遍了全网,终于解...

  • 2020-12-08

    2020-11-03 # 最近git clone项目一直报这个错。 * 于是乎为了解决这个问题我找遍了全网,终于解...

  • 2020-12-04

    2020-11-03 # 最近git clone项目一直报这个错。 * 于是乎为了解决这个问题我找遍了全网,终于解...

网友评论

      本文标题:2020-11-03

      本文链接:https://www.haomeiwen.com/subject/mjnbvktx.html