0
点赞
收藏
分享

微信扫一扫

torch.nn.Sequential

参考  nn.Sequential() - 云+社区 - 腾讯云

参考 torch.nn.Sequential - 云+社区 - 腾讯云

class torch.nn.Sequential(*args)[source]

顺序容器。模块将按照在构造函数中传递的顺序添加到它。或者,也可以传入模块的有序字典。例:

# Example of using Sequential
model = nn.Sequential(
          nn.Conv2d(1,20,5),
          nn.ReLU(),
          nn.Conv2d(20,64,5),
          nn.ReLU()
        )

# Example of using Sequential with OrderedDict
model = nn.Sequential(OrderedDict([
          ('conv1', nn.Conv2d(1,20,5)),
          ('relu1', nn.ReLU()),
          ('conv2', nn.Conv2d(20,64,5)),
          ('relu2', nn.ReLU())
        ]))
print(model)
print(type(model))

Output:
---------------------------------------------------------------
Sequential(
  (conv1): Conv2d(1, 20, kernel_size=(5, 5), stride=(1, 1))
  (relu1): ReLU()
  (conv2): Conv2d(20, 64, kernel_size=(5, 5), stride=(1, 1))
  (relu2): ReLU()
)
<class 'torch.nn.modules.container.Sequential'>
---------------------------------------------------------------
举报

相关推荐

0 条评论