目录
2. torch.flatten(input, start_dim=0, end_dim=-1)
7.pytorch中model eval和torch no grad()的区别
1. nn.Sequential
顺序容器。模块将按照在构造函数中传递的顺序添加到它。或者,也可以传入模块的有序字典。
# 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())
]))