이 코드를 실행하면 다음과 같이 출력됩니다.
Printing children ------------------------------ [Sequential( (0): Conv2d(3, 64, kernel_size=(5, 5), stride=(1, 1)) (1): ReLU(inplace=True) (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) ), Sequential( (0): Conv2d(64, 30, kernel_size=(5, 5), stride=(1, 1)) (1): ReLU(inplace=True) (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) ), Sequential( (0): Linear(in_features=750, out_features=10, bias=True) (1): ReLU(inplace=True) )] Printing Modules ------------------------------ [MLP( (layer1): Sequential( (0): Conv2d(3, 64, kernel_size=(5, 5), stride=(1, 1)) (1): ReLU(inplace=True) (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) ) (layer2): Sequential( (0): Conv2d(64, 30, kernel_size=(5, 5), stride=(1, 1)) (1): ReLU(inplace=True) (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) ) (layer3): Sequential( (0): Linear(in_features=750, out_features=10, bias=True) (1): ReLU(inplace=True) ) ), Sequential( (0): Conv2d(3, 64, kernel_size=(5, 5), stride=(1, 1)) (1): ReLU(inplace=True) (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) ), Conv2d(3, 64, kernel_size=(5, 5), stride=(1, 1)), ReLU(inplace=True), MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False), Sequential( (0): Conv2d(64, 30, kernel_size=(5, 5), stride=(1, 1)) (1): ReLU(inplace=True) (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) ), Conv2d(64, 30, kernel_size=(5, 5), stride=(1, 1)), ReLU(inplace=True), MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False), Sequential( (0): Linear(in_features=750, out_features=10, bias=True) (1): ReLU(inplace=True) ), Linear(in_features=750, out_features=10, bias=True), ReLU(inplace=True)]
nn.Sequential은 모델의 계층이 복잡할수록 효과가 뛰어납니다.