目录
- 理论知识
- Inception
- 卷积计算
- 模型结构
- 模型实现
- inception 结构
- GoogLeNet模型
- 打印模型结构
- 模型效果
- 总结与心得体会
理论知识
GoogLeNet首次出现就在2014年的ILSVRC比赛中获得冠军,最初的版本为InceptionV1。共有22层深,参数量5M。
可以达到同时期VGGNet的性能,但是参数量更少。
Inception
GoogleLeNet的核心模块是Inception模块。主要的思路是将提取特征的卷积并行,在同一层进行多种尺度的卷积计算。
初始版本(上图左侧所示)就是沿着上述的思路设计的,后面在初始版本的基础上,借鉴了Network-in-Network的思想,使用了1x1卷积实现降维操作,减小网络的参数量和计算量。如上图右侧所示。
卷积计算
卷积的参数量计算可以通俗的来讲为(原图通道数*目标通道数*卷积核宽*卷积核高 + 目标通道数)
例如:对100x100x128做通道为256的5x5卷积(填充方式为same,不改变图像尺寸)。参数量为128x256x5x5+256 = 819456
如果加入了一个通道为32的1x1卷积后,再做通道为256的5x5卷积。参数量就是1283211 + 32 + 3255256 + 256 = 209184 ,由此可见,加入1x1卷积参数量减少到原来的1/4左右
模型结构
InceptionV1的完整模块和结构图如下
模型实现
inception 结构
class inception_block(nn.Module):
def __init__(self, in_channels, ch1x1, ch3x3red, ch3x3, ch5x5red, ch5x5, pool_proj):
super().__init__()
# 1x1 分支
self.branch1 = nn.Sequential(
nn.Conv2d(in_channels, ch1x1, kernel_size=1),
nn.BatchNorm2d(ch1x1),
nn.ReLU(inplace=True)
)
# 1x1 -> 3x3 分支
self.branch2 = nn.Sequential(
nn.Conv2d(in_channels, ch3x3red, kernel_size=1),
nn.BatchNorm2d(ch3x3red),
nn.ReLU(inplace=True),
nn.Conv2d(ch3x3red, ch3x3, kernel_size=3, padding=1),
nn.BatchNorm2d(ch3x3),
nn.ReLU(inplace=True)
)
# 1x1 -> 5x5 分支
self.branch3 = nn.Sequential(
nn.Conv2d(in_channels, ch5x5red, kernel_size=1),
nn.BatchNorm2d(ch5x5red),
nn.ReLU(inplace=True),
nn.Conv2d(ch5x5red, ch5x5, kernel_size=5, padding=2),
nn.BatchNorm2d(ch5x5),
nn.ReLU(inplace=True)
)
# 3x3 -> 1x3 分支
self.branch4 = nn.Sequential(
nn.MaxPool2d(kernel_size=3, stride=1, padding=1),
nn.Conv2d(in_channels, pool_proj, kernel_size=1),
nn.BatchNorm2d(pool_proj),
nn.ReLU(inplace=True)
)
def forward(self, x):
branch1_output = self.branch1(x)
branch2_output = self.branch2(x)
branch3_output = self.branch3(x)
branch4_output = self.branch4(x)
outputs = [branch1_output, branch2_output, branch3_output, branch4_output]
return torch.cat(outputs, 1)
GoogLeNet模型
class InceptionV1(nn.Module):
def __init__(self, num_classes=1000):
super().__init__()
self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3)
self.maxpool1 = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
self.conv2 = nn.Conv2d(64, 64, kernel_size=1, stride=1, padding=0)
self.conv3 = nn.Conv2d(64, 192, kernel_size=3, stride=1, padding=1)
self.maxpool2 = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
self.inception3a = inception_block(192, 64, 96, 128, 16, 32, 32)
self.inception3b = inception_block(256, 128, 128, 192, 32, 96, 64)
self.maxpool3 = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
self.inception4a = inception_block(480, 192, 96, 208, 16, 48, 64)
self.inception4b = inception_block(512, 160, 112, 224, 24, 64, 64)
self.inception4c = inception_block(512, 128, 128, 256, 24, 64, 64)
self.inception4d = inception_block(512, 112, 144, 288, 32, 64, 64)
self.inception4e = inception_block(528, 256, 160, 320, 32, 128, 128)
self.maxpool4 = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
self.inception5a = inception_block(832, 256, 160, 320, 32, 128, 128)
self.inception5b = nn.Sequential(
inception_block(832, 384, 192, 384, 48, 128, 128),
nn.AvgPool2d(kernel_size=7, stride=1, padding=0),
nn.Dropout(0.4)
)
# 全连接层
self.classifier = nn.Sequential(
nn.Linear(in_features=1024, out_features=1024),
nn.ReLU(),
nn.Linear(in_features=1024, out_features=num_classes),
nn.Softmax(dim=1)
)
def forward(self, x):
x = self.conv1(x)
x = F.relu(x)
x = self.maxpool1(x)
x = self.conv2(x)
x = F.relu(x)
x = self.conv3(x)
x = F.relu(x)
x = self.maxpool2(x)
x = self.inception3a(x)
x = self.inception3b(x)
x = self.maxpool3(x)
x = self.inception4a(x)
x = self.inception4b(x)
x = self.inception4c(x)
x = self.inception4d(x)
x = self.inception4e(x)
x = self.maxpool4(x)
x = self.inception5a(x)
x = self.inception5b(x)
x = torch.flatten(x, start_dim=1)
x = self.classifier(x)
return x
打印模型结构
model = InceptionV1().to(device)
summary(model, input_size=(16, 3, 224, 224))
==========================================================================================
Layer (type:depth-idx) Output Shape Param #
==========================================================================================
InceptionV1 [16, 1000] --
├─Conv2d: 1-1 [16, 64, 112, 112] 9,472
├─MaxPool2d: 1-2 [16, 64, 56, 56] --
├─Conv2d: 1-3 [16, 64, 56, 56] 4,160
├─Conv2d: 1-4 [16, 192, 56, 56] 110,784
├─MaxPool2d: 1-5 [16, 192, 28, 28] --
├─inception_block: 1-6 [16, 256, 28, 28] --
│ └─Sequential: 2-1 [16, 64, 28, 28] --
│ │ └─Conv2d: 3-1 [16, 64, 28, 28] 12,352
│ │ └─BatchNorm2d: 3-2 [16, 64, 28, 28] 128
│ │ └─ReLU: 3-3 [16, 64, 28, 28] --
│ └─Sequential: 2-2 [16, 128, 28, 28] --
│ │ └─Conv2d: 3-4 [16, 96, 28, 28] 18,528
│ │ └─BatchNorm2d: 3-5 [16, 96, 28, 28] 192
│ │ └─ReLU: 3-6 [16, 96, 28, 28] --
│ │ └─Conv2d: 3-7 [16, 128, 28, 28] 110,720
│ │ └─BatchNorm2d: 3-8 [16, 128, 28, 28] 256
│ │ └─ReLU: 3-9 [16, 128, 28, 28] --
│ └─Sequential: 2-3 [16, 32, 28, 28] --
│ │ └─Conv2d: 3-10 [16, 16, 28, 28] 3,088
│ │ └─BatchNorm2d: 3-11 [16, 16, 28, 28] 32
│ │ └─ReLU: 3-12 [16, 16, 28, 28] --
│ │ └─Conv2d: 3-13 [16, 32, 28, 28] 12,832
│ │ └─BatchNorm2d: 3-14 [16, 32, 28, 28] 64
│ │ └─ReLU: 3-15 [16, 32, 28, 28] --
│ └─Sequential: 2-4 [16, 32, 28, 28] --
│ │ └─MaxPool2d: 3-16 [16, 192, 28, 28] --
│ │ └─Conv2d: 3-17 [16, 32, 28, 28] 6,176
│ │ └─BatchNorm2d: 3-18 [16, 32, 28, 28] 64
│ │ └─ReLU: 3-19 [16, 32, 28, 28] --
├─inception_block: 1-7 [16, 480, 28, 28] --
│ └─Sequential: 2-5 [16, 128, 28, 28] --
│ │ └─Conv2d: 3-20 [16, 128, 28, 28] 32,896
│ │ └─BatchNorm2d: 3-21 [16, 128, 28, 28] 256
│ │ └─ReLU: 3-22 [16, 128, 28, 28] --
│ └─Sequential: 2-6 [16, 192, 28, 28] --
│ │ └─Conv2d: 3-23 [16, 128, 28, 28] 32,896
│ │ └─BatchNorm2d: 3-24 [16, 128, 28, 28] 256
│ │ └─ReLU: 3-25 [16, 128, 28, 28] --
│ │ └─Conv2d: 3-26 [16, 192, 28, 28] 221,376
│ │ └─BatchNorm2d: 3-27 [16, 192, 28, 28] 384
│ │ └─ReLU: 3-28 [16, 192, 28, 28] --
│ └─Sequential: 2-7 [16, 96, 28, 28] --
│ │ └─Conv2d: 3-29 [16, 32, 28, 28] 8,224
│ │ └─BatchNorm2d: 3-30 [16, 32, 28, 28] 64
│ │ └─ReLU: 3-31 [16, 32, 28, 28] --
│ │ └─Conv2d: 3-32 [16, 96, 28, 28] 76,896
│ │ └─BatchNorm2d: 3-33 [16, 96, 28, 28] 192
│ │ └─ReLU: 3-34 [16, 96, 28, 28] --
│ └─Sequential: 2-8 [16, 64, 28, 28] --
│ │ └─MaxPool2d: 3-35 [16, 256, 28, 28] --
│ │ └─Conv2d: 3-36 [16, 64, 28, 28] 16,448
│ │ └─BatchNorm2d: 3-37 [16, 64, 28, 28] 128
│ │ └─ReLU: 3-38 [16, 64, 28, 28] --
├─MaxPool2d: 1-8 [16, 480, 14, 14] --
├─inception_block: 1-9 [16, 512, 14, 14] --
│ └─Sequential: 2-9 [16, 192, 14, 14] --
│ │ └─Conv2d: 3-39 [16, 192, 14, 14] 92,352
│ │ └─BatchNorm2d: 3-40 [16, 192, 14, 14] 384
│ │ └─ReLU: 3-41 [16, 192, 14, 14] --
│ └─Sequential: 2-10 [16, 208, 14, 14] --
│ │ └─Conv2d: 3-42 [16, 96, 14, 14] 46,176
│ │ └─BatchNorm2d: 3-43 [16, 96, 14, 14] 192
│ │ └─ReLU: 3-44 [16, 96, 14, 14] --
│ │ └─Conv2d: 3-45 [16, 208, 14, 14] 179,920
│ │ └─BatchNorm2d: 3-46 [16, 208, 14, 14] 416
│ │ └─ReLU: 3-47 [16, 208, 14, 14] --
│ └─Sequential: 2-11 [16, 48, 14, 14] --
│ │ └─Conv2d: 3-48 [16, 16, 14, 14] 7,696
│ │ └─BatchNorm2d: 3-49 [16, 16, 14, 14] 32
│ │ └─ReLU: 3-50 [16, 16, 14, 14] --
│ │ └─Conv2d: 3-51 [16, 48, 14, 14] 19,248
│ │ └─BatchNorm2d: 3-52 [16, 48, 14, 14] 96
│ │ └─ReLU: 3-53 [16, 48, 14, 14] --
│ └─Sequential: 2-12 [16, 64, 14, 14] --
│ │ └─MaxPool2d: 3-54 [16, 480, 14, 14] --
│ │ └─Conv2d: 3-55 [16, 64, 14, 14] 30,784
│ │ └─BatchNorm2d: 3-56 [16, 64, 14, 14] 128
│ │ └─ReLU: 3-57 [16, 64, 14, 14] --
├─inception_block: 1-10 [16, 512, 14, 14] --
│ └─Sequential: 2-13 [16, 160, 14, 14] --
│ │ └─Conv2d: 3-58 [16, 160, 14, 14] 82,080
│ │ └─BatchNorm2d: 3-59 [16, 160, 14, 14] 320
│ │ └─ReLU: 3-60 [16, 160, 14, 14] --
│ └─Sequential: 2-14 [16, 224, 14, 14] --
│ │ └─Conv2d: 3-61 [16, 112, 14, 14] 57,456
│ │ └─BatchNorm2d: 3-62 [16, 112, 14, 14] 224
│ │ └─ReLU: 3-63 [16, 112, 14, 14] --
│ │ └─Conv2d: 3-64 [16, 224, 14, 14] 226,016
│ │ └─BatchNorm2d: 3-65 [16, 224, 14, 14] 448
│ │ └─ReLU: 3-66 [16, 224, 14, 14] --
│ └─Sequential: 2-15 [16, 64, 14, 14] --
│ │ └─Conv2d: 3-67 [16, 24, 14, 14] 12,312
│ │ └─BatchNorm2d: 3-68 [16, 24, 14, 14] 48
│ │ └─ReLU: 3-69 [16, 24, 14, 14] --
│ │ └─Conv2d: 3-70 [16, 64, 14, 14] 38,464
│ │ └─BatchNorm2d: 3-71 [16, 64, 14, 14] 128
│ │ └─ReLU: 3-72 [16, 64, 14, 14] --
│ └─Sequential: 2-16 [16, 64, 14, 14] --
│ │ └─MaxPool2d: 3-73 [16, 512, 14, 14] --
│ │ └─Conv2d: 3-74 [16, 64, 14, 14] 32,832
│ │ └─BatchNorm2d: 3-75 [16, 64, 14, 14] 128
│ │ └─ReLU: 3-76 [16, 64, 14, 14] --
├─inception_block: 1-11 [16, 512, 14, 14] --
│ └─Sequential: 2-17 [16, 128, 14, 14] --
│ │ └─Conv2d: 3-77 [16, 128, 14, 14] 65,664
│ │ └─BatchNorm2d: 3-78 [16, 128, 14, 14] 256
│ │ └─ReLU: 3-79 [16, 128, 14, 14] --
│ └─Sequential: 2-18 [16, 256, 14, 14] --
│ │ └─Conv2d: 3-80 [16, 128, 14, 14] 65,664
│ │ └─BatchNorm2d: 3-81 [16, 128, 14, 14] 256
│ │ └─ReLU: 3-82 [16, 128, 14, 14] --
│ │ └─Conv2d: 3-83 [16, 256, 14, 14] 295,168
│ │ └─BatchNorm2d: 3-84 [16, 256, 14, 14] 512
│ │ └─ReLU: 3-85 [16, 256, 14, 14] --
│ └─Sequential: 2-19 [16, 64, 14, 14] --
│ │ └─Conv2d: 3-86 [16, 24, 14, 14] 12,312
│ │ └─BatchNorm2d: 3-87 [16, 24, 14, 14] 48
│ │ └─ReLU: 3-88 [16, 24, 14, 14] --
│ │ └─Conv2d: 3-89 [16, 64, 14, 14] 38,464
│ │ └─BatchNorm2d: 3-90 [16, 64, 14, 14] 128
│ │ └─ReLU: 3-91 [16, 64, 14, 14] --
│ └─Sequential: 2-20 [16, 64, 14, 14] --
│ │ └─MaxPool2d: 3-92 [16, 512, 14, 14] --
│ │ └─Conv2d: 3-93 [16, 64, 14, 14] 32,832
│ │ └─BatchNorm2d: 3-94 [16, 64, 14, 14] 128
│ │ └─ReLU: 3-95 [16, 64, 14, 14] --
├─inception_block: 1-12 [16, 528, 14, 14] --
│ └─Sequential: 2-21 [16, 112, 14, 14] --
│ │ └─Conv2d: 3-96 [16, 112, 14, 14] 57,456
│ │ └─BatchNorm2d: 3-97 [16, 112, 14, 14] 224
│ │ └─ReLU: 3-98 [16, 112, 14, 14] --
│ └─Sequential: 2-22 [16, 288, 14, 14] --
│ │ └─Conv2d: 3-99 [16, 144, 14, 14] 73,872
│ │ └─BatchNorm2d: 3-100 [16, 144, 14, 14] 288
│ │ └─ReLU: 3-101 [16, 144, 14, 14] --
│ │ └─Conv2d: 3-102 [16, 288, 14, 14] 373,536
│ │ └─BatchNorm2d: 3-103 [16, 288, 14, 14] 576
│ │ └─ReLU: 3-104 [16, 288, 14, 14] --
│ └─Sequential: 2-23 [16, 64, 14, 14] --
│ │ └─Conv2d: 3-105 [16, 32, 14, 14] 16,416
│ │ └─BatchNorm2d: 3-106 [16, 32, 14, 14] 64
│ │ └─ReLU: 3-107 [16, 32, 14, 14] --
│ │ └─Conv2d: 3-108 [16, 64, 14, 14] 51,264
│ │ └─BatchNorm2d: 3-109 [16, 64, 14, 14] 128
│ │ └─ReLU: 3-110 [16, 64, 14, 14] --
│ └─Sequential: 2-24 [16, 64, 14, 14] --
│ │ └─MaxPool2d: 3-111 [16, 512, 14, 14] --
│ │ └─Conv2d: 3-112 [16, 64, 14, 14] 32,832
│ │ └─BatchNorm2d: 3-113 [16, 64, 14, 14] 128
│ │ └─ReLU: 3-114 [16, 64, 14, 14] --
├─inception_block: 1-13 [16, 832, 14, 14] --
│ └─Sequential: 2-25 [16, 256, 14, 14] --
│ │ └─Conv2d: 3-115 [16, 256, 14, 14] 135,424
│ │ └─BatchNorm2d: 3-116 [16, 256, 14, 14] 512
│ │ └─ReLU: 3-117 [16, 256, 14, 14] --
│ └─Sequential: 2-26 [16, 320, 14, 14] --
│ │ └─Conv2d: 3-118 [16, 160, 14, 14] 84,640
│ │ └─BatchNorm2d: 3-119 [16, 160, 14, 14] 320
│ │ └─ReLU: 3-120 [16, 160, 14, 14] --
│ │ └─Conv2d: 3-121 [16, 320, 14, 14] 461,120
│ │ └─BatchNorm2d: 3-122 [16, 320, 14, 14] 640
│ │ └─ReLU: 3-123 [16, 320, 14, 14] --
│ └─Sequential: 2-27 [16, 128, 14, 14] --
│ │ └─Conv2d: 3-124 [16, 32, 14, 14] 16,928
│ │ └─BatchNorm2d: 3-125 [16, 32, 14, 14] 64
│ │ └─ReLU: 3-126 [16, 32, 14, 14] --
│ │ └─Conv2d: 3-127 [16, 128, 14, 14] 102,528
│ │ └─BatchNorm2d: 3-128 [16, 128, 14, 14] 256
│ │ └─ReLU: 3-129 [16, 128, 14, 14] --
│ └─Sequential: 2-28 [16, 128, 14, 14] --
│ │ └─MaxPool2d: 3-130 [16, 528, 14, 14] --
│ │ └─Conv2d: 3-131 [16, 128, 14, 14] 67,712
│ │ └─BatchNorm2d: 3-132 [16, 128, 14, 14] 256
│ │ └─ReLU: 3-133 [16, 128, 14, 14] --
├─MaxPool2d: 1-14 [16, 832, 7, 7] --
├─inception_block: 1-15 [16, 832, 7, 7] --
│ └─Sequential: 2-29 [16, 256, 7, 7] --
│ │ └─Conv2d: 3-134 [16, 256, 7, 7] 213,248
│ │ └─BatchNorm2d: 3-135 [16, 256, 7, 7] 512
│ │ └─ReLU: 3-136 [16, 256, 7, 7] --
│ └─Sequential: 2-30 [16, 320, 7, 7] --
│ │ └─Conv2d: 3-137 [16, 160, 7, 7] 133,280
│ │ └─BatchNorm2d: 3-138 [16, 160, 7, 7] 320
│ │ └─ReLU: 3-139 [16, 160, 7, 7] --
│ │ └─Conv2d: 3-140 [16, 320, 7, 7] 461,120
│ │ └─BatchNorm2d: 3-141 [16, 320, 7, 7] 640
│ │ └─ReLU: 3-142 [16, 320, 7, 7] --
│ └─Sequential: 2-31 [16, 128, 7, 7] --
│ │ └─Conv2d: 3-143 [16, 32, 7, 7] 26,656
│ │ └─BatchNorm2d: 3-144 [16, 32, 7, 7] 64
│ │ └─ReLU: 3-145 [16, 32, 7, 7] --
│ │ └─Conv2d: 3-146 [16, 128, 7, 7] 102,528
│ │ └─BatchNorm2d: 3-147 [16, 128, 7, 7] 256
│ │ └─ReLU: 3-148 [16, 128, 7, 7] --
│ └─Sequential: 2-32 [16, 128, 7, 7] --
│ │ └─MaxPool2d: 3-149 [16, 832, 7, 7] --
│ │ └─Conv2d: 3-150 [16, 128, 7, 7] 106,624
│ │ └─BatchNorm2d: 3-151 [16, 128, 7, 7] 256
│ │ └─ReLU: 3-152 [16, 128, 7, 7] --
├─Sequential: 1-16 [16, 1024, 1, 1] --
│ └─inception_block: 2-33 [16, 1024, 7, 7] --
│ │ └─Sequential: 3-153 [16, 384, 7, 7] 320,640
│ │ └─Sequential: 3-154 [16, 384, 7, 7] 825,024
│ │ └─Sequential: 3-155 [16, 128, 7, 7] 194,064
│ │ └─Sequential: 3-156 [16, 128, 7, 7] 106,880
│ └─AvgPool2d: 2-34 [16, 1024, 1, 1] --
│ └─Dropout: 2-35 [16, 1024, 1, 1] --
├─Sequential: 1-17 [16, 1000] --
│ └─Linear: 2-36 [16, 1024] 1,049,600
│ └─ReLU: 2-37 [16, 1024] --
│ └─Linear: 2-38 [16, 1000] 1,025,000
│ └─Softmax: 2-39 [16, 1000] --
==========================================================================================
Total params: 8,062,072
Trainable params: 8,062,072
Non-trainable params: 0
Total mult-adds (Units.GIGABYTES): 25.39
==========================================================================================
Input size (MB): 9.63
Forward/backward pass size (MB): 620.64
Params size (MB): 32.25
Estimated Total Size (MB): 662.52
==========================================================================================
模型效果
使用GoogLeNet InceptionV1来进行猴痘图像识别,过程如下
Epoch: 1, Train_acc: 63.2%, Train_loss: 0.653, Test_acc: 64.1%, Test_loss:0.645
Epoch: 2, Train_acc: 67.0%, Train_loss: 0.626, Test_acc: 67.6%, Test_loss:0.621
Epoch: 3, Train_acc: 68.2%, Train_loss: 0.621, Test_acc: 69.0%, Test_loss:0.615
Epoch: 4, Train_acc: 68.9%, Train_loss: 0.608, Test_acc: 62.9%, Test_loss:0.641
Epoch: 5, Train_acc: 72.2%, Train_loss: 0.583, Test_acc: 64.3%, Test_loss:0.652
Epoch: 6, Train_acc: 74.5%, Train_loss: 0.556, Test_acc: 64.6%, Test_loss:0.640
Epoch: 7, Train_acc: 74.5%, Train_loss: 0.561, Test_acc: 70.6%, Test_loss:0.592
Epoch: 8, Train_acc: 77.2%, Train_loss: 0.535, Test_acc: 67.8%, Test_loss:0.621
Epoch: 9, Train_acc: 78.3%, Train_loss: 0.528, Test_acc: 75.3%, Test_loss:0.553
Epoch: 10, Train_acc: 78.3%, Train_loss: 0.527, Test_acc: 71.6%, Test_loss:0.579
Epoch: 11, Train_acc: 78.1%, Train_loss: 0.528, Test_acc: 76.2%, Test_loss:0.532
Epoch: 12, Train_acc: 79.4%, Train_loss: 0.516, Test_acc: 63.6%, Test_loss:0.654
Epoch: 13, Train_acc: 77.9%, Train_loss: 0.529, Test_acc: 67.4%, Test_loss:0.619
Epoch: 14, Train_acc: 81.0%, Train_loss: 0.498, Test_acc: 66.0%, Test_loss:0.624
Epoch: 15, Train_acc: 83.8%, Train_loss: 0.470, Test_acc: 78.8%, Test_loss:0.506
Epoch: 16, Train_acc: 85.3%, Train_loss: 0.456, Test_acc: 81.4%, Test_loss:0.499
Epoch: 17, Train_acc: 83.4%, Train_loss: 0.471, Test_acc: 80.0%, Test_loss:0.497
Epoch: 18, Train_acc: 84.8%, Train_loss: 0.461, Test_acc: 78.1%, Test_loss:0.517
Epoch: 19, Train_acc: 85.9%, Train_loss: 0.452, Test_acc: 79.3%, Test_loss:0.503
Epoch: 20, Train_acc: 86.9%, Train_loss: 0.439, Test_acc: 77.9%, Test_loss:0.521
Epoch: 21, Train_acc: 87.5%, Train_loss: 0.436, Test_acc: 69.7%, Test_loss:0.610
Epoch: 22, Train_acc: 85.3%, Train_loss: 0.455, Test_acc: 84.1%, Test_loss:0.464
Epoch: 23, Train_acc: 86.7%, Train_loss: 0.442, Test_acc: 80.2%, Test_loss:0.504
Epoch: 24, Train_acc: 86.7%, Train_loss: 0.444, Test_acc: 75.5%, Test_loss:0.561
Epoch: 25, Train_acc: 86.2%, Train_loss: 0.450, Test_acc: 85.5%, Test_loss:0.448
Epoch: 26, Train_acc: 88.3%, Train_loss: 0.429, Test_acc: 79.5%, Test_loss:0.502
Epoch: 27, Train_acc: 87.4%, Train_loss: 0.432, Test_acc: 85.5%, Test_loss:0.443
Epoch: 28, Train_acc: 89.7%, Train_loss: 0.412, Test_acc: 77.2%, Test_loss:0.529
Epoch: 29, Train_acc: 89.7%, Train_loss: 0.417, Test_acc: 77.9%, Test_loss:0.532
Epoch: 30, Train_acc: 87.0%, Train_loss: 0.442, Test_acc: 84.1%, Test_loss:0.478
Epoch: 31, Train_acc: 86.9%, Train_loss: 0.440, Test_acc: 82.1%, Test_loss:0.487
Epoch: 32, Train_acc: 88.2%, Train_loss: 0.428, Test_acc: 82.8%, Test_loss:0.477
Epoch: 33, Train_acc: 88.7%, Train_loss: 0.421, Test_acc: 76.2%, Test_loss:0.542
Epoch: 34, Train_acc: 87.3%, Train_loss: 0.436, Test_acc: 83.9%, Test_loss:0.470
Epoch: 35, Train_acc: 88.5%, Train_loss: 0.429, Test_acc: 85.1%, Test_loss:0.459
Epoch: 36, Train_acc: 89.1%, Train_loss: 0.421, Test_acc: 86.0%, Test_loss:0.449
Epoch: 37, Train_acc: 89.6%, Train_loss: 0.416, Test_acc: 86.5%, Test_loss:0.438
Epoch: 38, Train_acc: 88.0%, Train_loss: 0.427, Test_acc: 87.6%, Test_loss:0.433
Epoch: 39, Train_acc: 90.3%, Train_loss: 0.406, Test_acc: 88.6%, Test_loss:0.426
Epoch: 40, Train_acc: 90.4%, Train_loss: 0.405, Test_acc: 87.9%, Test_loss:0.431
Epoch: 41, Train_acc: 91.8%, Train_loss: 0.391, Test_acc: 87.6%, Test_loss:0.431
Epoch: 42, Train_acc: 91.9%, Train_loss: 0.392, Test_acc: 82.8%, Test_loss:0.476
Epoch: 43, Train_acc: 92.5%, Train_loss: 0.388, Test_acc: 88.8%, Test_loss:0.419
Epoch: 44, Train_acc: 91.6%, Train_loss: 0.393, Test_acc: 83.0%, Test_loss:0.468
Epoch: 45, Train_acc: 91.0%, Train_loss: 0.401, Test_acc: 89.0%, Test_loss:0.419
Epoch: 46, Train_acc: 91.9%, Train_loss: 0.394, Test_acc: 88.1%, Test_loss:0.426
Epoch: 47, Train_acc: 92.9%, Train_loss: 0.381, Test_acc: 88.6%, Test_loss:0.430
Epoch: 48, Train_acc: 94.1%, Train_loss: 0.372, Test_acc: 86.7%, Test_loss:0.450
Epoch: 49, Train_acc: 91.4%, Train_loss: 0.394, Test_acc: 89.0%, Test_loss:0.422
Epoch: 50, Train_acc: 93.2%, Train_loss: 0.379, Test_acc: 90.4%, Test_loss:0.411
Done
总结与心得体会
通过50次迭代的结果发现,模型在测试集上的准确率已经可以达到90.4%。对比之前的ResNeXt有精度提升。另外,通过对Inception结构的学习,学到了一些模型优化的思路:1. 是并行,将过长的网络,通过一定的策略,修改成并行计算,可以减少网络层数
2. 是将NxN的卷积变成1xN->Nx1来减少参数量
3. 是在卷积操作前,通过1x1卷积降维
4. Inception结构虽然好,但作者属于是在一些小的特征提取层后才应用的,原始图像先是经过了像VGGNet一样的3个卷积和2个最大池化后,才接入Inception结构。所以我感觉Inception结构是有利于浅层特征中提取高层特征,而从原始图像中获取浅层特征这一步,不可以直接省略。