CNNの歴史。 この歴史に沿って、FassionMNISTに対し、nn.moduleで各AIモデルに沿ったモデルを作る。 VGG 3x3 の畳み込みをただ深く積み重ねる class VGG_Fashion(nn.Module): def __init__(self): super(VGG_Fashion, self).__init__() self.features = nn.Sequential( # Block 1 nn.Conv2d(1, 32, 3, padding=1), nn.ReLU(), nn.Conv2d(32, 32, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2), # 14x14 # Block 2 nn.Conv2d(32, 64, 3, padding=1), nn.ReLU(), nn.Conv2d(64, 64, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2) # 7x7 ) self.classifier = nn.Sequential( nn.Linear(64 * 7 * 7, 512), nn.ReLU(), nn.Dropout(0.5), nn.Linear(512, 10) ) GoogLeNet 1x1 フィルタを使用して次元数を削減している。(※ 5x5 畳み込みはサイズの都合上、省略) class InceptionModule(nn.Module): def __init__(self, in_ch, out_1x1, out_3x3): super().__init__() self.branch1 = nn.Conv2d(in_ch, out_1x1, kernel_size=1) self.branch2 = nn.Sequential( nn.Conv2d(in_ch, out_3x3//2, kernel_size=1), nn.Conv2d(out_3x3//2, out_3x3, kernel_size=3, padding=1) ) def forward(self, x): ...