Pelee.Pytorch
Pelee.Pytorch copied to clipboard
wrong when construct _DenseLayer
class _DenseLayer(nn.Module): """docstring for _DenseLayer"""
def __init__(self, num_input_features, growth_rate, bottleneck_width, drop_rate):
super(_DenseLayer, self).__init__()
growth_rate = growth_rate // 2
inter_channel = int(growth_rate * bottleneck_width / 4) * 4
if inter_channel > num_input_features / 2:
inter_channel = int(num_input_features / 8) * 4
print('adjust inter_channel to ', inter_channel)
self.branch1a = conv_bn_relu(
num_input_features, inter_channel, kernel_size=1)
self.branch1b = conv_bn_relu(
inter_channel, growth_rate, kernel_size=3, padding=1)
self.branch2a = conv_bn_relu(
num_input_features, inter_channel, kernel_size=1)
self.branch2b = conv_bn_relu(
inter_channel, growth_rate, kernel_size=3, padding=1)
self.branch2c = conv_bn_relu(
growth_rate, growth_rate, kernel_size=3, padding=1)
def forward(self, x):
out1 = self.branch1a(x)
out1 = self.branch1b(out1)
out2 = self.branch2a(x)
out2 = self.branch2b(out2)
out3 = self.branch2c(out2)
out = torch.cat([x, out1, out2], dim=1) // torch.cat([x, out1, out3], dim=1)
return out