# Codeblock 8a class MobileNetV1(nn.Module): def __init__(self): super().__init__() self.first_conv = FirstConv() #(1) self.depthwise_sep_conv0 = DepthwiseSeparableConv(in_channels=32, out_channels=64) self.depthwise_sep_conv1 = DepthwiseSeparableConv(in_channels=64, out_channels=128, downsample=True) self.depthwise_sep_conv2 = DepthwiseSeparableConv(in_channels=128, out_channels=128) self.depthwise_sep_conv3 = DepthwiseSeparableConv(in_channels=128, out_channels=256, downsample=True) self.depthwise_sep_conv4 = DepthwiseSeparableConv(in_channels=256, out_channels=256) self.depthwise_sep_conv5 = DepthwiseSeparableConv(in_channels=256, out_channels=512, downsample=True) self.depthwise_sep_conv6 = nn.ModuleList( [DepthwiseSeparableConv(in_channels=512, out_channels=512) for _ in range(5)] ) self.depthwise_sep_conv7 = DepthwiseSeparableConv(in_channels=512, out_channels=1024, downsample=True) self.depthwise_sep_conv8 = DepthwiseSeparableConv(in_channels=1024, #(2) out_channels=1024) num_out_channels = self.depthwise_sep_conv8.pwconv.out_channels #(3) self.avgpool = nn.AdaptiveAvgPool2d(output_size=(1,1)) #(4) self.fc = nn.Linear(in_features=num_out_channels, #(5) out_features=NUM_CLASSES) self.softmax = nn.Softmax(dim=1) #(6)