def __init__(self, block, layers, output_stride, num_classes=1000, input_channels=3):
    super(ResNet, self).__init__()
    if (output_stride == 8):
        stride = [1, 2, 1, 1]
        dilation = [1, 1, 2, 2]
    elif (output_stride == 16):
        stride = [1, 2, 2, 1]
        dilation = [1, 1, 1, 2]
    self.inplanes = 64
    self.conv1 = nn.Conv2d(input_channels, 64, kernel_size=7, stride=2, padding=3, bias=False)
    self.bn1 = nn.BatchNorm2d(64)
    self.relu = nn.ReLU(inplace=True)
    self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
    self.layer1 = self._make_layer(block, 64, layers[0], stride=stride[0], dilation=dilation[0])
    self.layer2 = self._make_layer(block, 128, layers[1], stride=stride[1], dilation=dilation[1])
    self.layer3 = self._make_layer(block, 256, layers[2], stride=stride[2], dilation=dilation[2])
    self.layer4 = self._make_layer(block, 512, layers[3], stride=stride[3], dilation=dilation[3])
    self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
    self.fc = nn.Linear((512 * block.expansion), num_classes)
    for m in self.modules():
        if isinstance(m, nn.Conv2d):
            nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
        elif isinstance(m, nn.BatchNorm2d):
            nn.init.constant_(m.weight, 1)
            nn.init.constant_(m.bias, 0)
def __init__(self, block, layers, output_stride, num_classes=1000, input_channels=3):
    super(ResNet, self).__init__()
    if (output_stride == 8):
        stride = [1, 2, 1, 1]
        dilation = [1, 1, 2, 2]
    elif (output_stride == 16):
        stride = [1, 2, 2, 1]
        dilation = [1, 1, 1, 2]
    self.inplanes = 64
    self.conv1 = nn.Conv2d(input_channels, 64, kernel_size=7, stride=2, padding=3, bias=False)
    self.bn1 = nn.BatchNorm2d(64)
    self.relu = nn.ReLU(inplace=True)
    self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
    self.layer1 = self._make_layer(block, 64, layers[0], stride=stride[0], dilation=dilation[0])
    self.layer2 = self._make_layer(block, 128, layers[1], stride=stride[1], dilation=dilation[1])
    self.layer3 = self._make_layer(block, 256, layers[2], stride=stride[2], dilation=dilation[2])
    self.layer4 = self._make_layer(block, 512, layers[3], stride=stride[3], dilation=dilation[3])
    self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
    self.fc = nn.Linear((512 * block.expansion), num_classes)
    for m in self.modules():
        if isinstance(m, nn.Conv2d):
            nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
        elif isinstance(m, nn.BatchNorm2d):
            nn.init.constant_(m.weight, 1)
            nn.init.constant_(m.bias, 0)