def __init__(self, in_channels, out_channels, bottleneck, p):
"""
Initialize the different parts of the SubBlock.
Params
------
- in_channels: number of input channels in the convolution.
- out_channels: number of output channels in the convolution.
- bottleneck: if true, applies the bottleneck variant of H(x).
- p: if greater than 0, applies dropout after the convolution.
"""
super(SubBlock, self).__init__()
self.bottleneck = bottleneck
self.p = p
in_channels_2 = in_channels
out_channels_2 = out_channels
if bottleneck:
in_channels_1 = in_channels
out_channels_1 = out_channels * 4
in_channels_2 = out_channels_1
self.bn1 = nn.BatchNorm2d(in_channels_1)
self.conv1 = nn.Conv2d(in_channels_1,
out_channels_1,
kernel_size=1)
self.bn2 = nn.BatchNorm2d(in_channels_2)
self.conv2 = nn.Conv2d(in_channels_2,
out_channels_2,
kernel_size=3,
padding=1)
评论列表
文章目录