# Codeblock 5 class ConvBlock(nn.Module): def __init__(self, in_channels, #(1) out_channels, #(2) kernel_size, #(3) stride, #(4) padding, #(5) groups=1, #(6) batchnorm=True, #(7) activation=nn.ReLU6()): #(8) super().__init__() bias = False if batchnorm else True #(9) self.conv = nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=stride, padding=padding, groups=groups, bias=bias) self.bn = nn.BatchNorm2d(num_features=out_channels) if batchnorm else nn.Identity() #(10) self.activation = activation def forward(self, x): #(11) print(f'original\t\t: {x.size()}') x = self.conv(x) print(f'after conv\t\t: {x.size()}') x = self.bn(x) print(f'after bn\t\t: {x.size()}') x = self.activation(x) print(f'after activation\t: {x.size()}') return x