Classification/models/resnet_imagenet.py [46:145]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
                 base_width=64, dilation=1, norm_layer=None, deconv=None):
        super(BasicBlock, self).__init__()

        if norm_layer is None:
            norm_layer = nn.BatchNorm2d
        if groups != 1 or base_width != 64:
            raise ValueError('BasicBlock only supports groups=1 and base_width=64')
        if dilation > 1:
            raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
        # Both self.conv1 and self.downsample layers downsample the input when stride != 1
        self.conv1 = conv3x3(inplanes, planes, stride,deconv=deconv)
        self.relu = nn.ReLU(inplace=True)
        self.conv2 = conv3x3(planes, planes,deconv=deconv)
        self.downsample = downsample
        self.stride = stride
        if not deconv:
            self.bn1 = norm_layer(planes)
            self.bn2 = norm_layer(planes)

    def forward(self, x):
        identity = x

        out = self.conv1(x)

        if hasattr(self,'bn1'):
            out = self.bn1(out)

        out = self.relu(out)

        out = self.conv2(out)

        if hasattr(self, 'bn2'):
            out = self.bn2(out)

        if self.downsample is not None:
            identity = self.downsample(x)

        out += identity
        out = self.relu(out)

        return out


class Bottleneck(nn.Module):
    expansion = 4

    def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
                 base_width=64, dilation=1, norm_layer=None,deconv=None):
        super(Bottleneck, self).__init__()
        if norm_layer is None:
            norm_layer = nn.BatchNorm2d
        width = int(planes * (base_width / 64.)) * groups
        # Both self.conv2 and self.downsample layers downsample the input when stride != 1
        self.conv1 = conv1x1(inplanes, width,deconv=deconv)
        self.conv2 = conv3x3(width, width, stride, groups, dilation,deconv=deconv)
        self.conv3 = conv1x1(width, planes * self.expansion,deconv=deconv)
        self.relu = nn.ReLU(inplace=True)
        self.downsample = downsample
        self.stride = stride
        if not deconv:
            self.bn1 = norm_layer(width)
            self.bn2 = norm_layer(width)
            self.bn3 = norm_layer(planes * self.expansion)

    def forward(self, x):
        identity = x

        out = self.conv1(x)

        if hasattr(self,'bn1'):
            out = self.bn1(out)

        out = self.relu(out)

        out = self.conv2(out)

        if hasattr(self, 'bn2'):
            out = self.bn2(out)

        out = self.relu(out)

        out = self.conv3(out)

        if hasattr(self, 'bn3'):
            out = self.bn3(out)

        if self.downsample is not None:
            identity = self.downsample(x)

        out += identity
        out = self.relu(out)

        return out


class ResNet(nn.Module):

    def __init__(self, block, layers, num_classes=1000, zero_init_residual=False,
                 groups=1, width_per_group=64, replace_stride_with_dilation=None,
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



Segmentation/models/resnetd.py [41:140]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
                 base_width=64, dilation=1, norm_layer=None, deconv=None):
        super(BasicBlock, self).__init__()

        if norm_layer is None:
            norm_layer = nn.BatchNorm2d
        if groups != 1 or base_width != 64:
            raise ValueError('BasicBlock only supports groups=1 and base_width=64')
        if dilation > 1:
            raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
        # Both self.conv1 and self.downsample layers downsample the input when stride != 1
        self.conv1 = conv3x3(inplanes, planes, stride,deconv=deconv)
        self.relu = nn.ReLU(inplace=True)
        self.conv2 = conv3x3(planes, planes,deconv=deconv)
        self.downsample = downsample
        self.stride = stride
        if not deconv:
            self.bn1 = norm_layer(planes)
            self.bn2 = norm_layer(planes)

    def forward(self, x):
        identity = x

        out = self.conv1(x)

        if hasattr(self,'bn1'):
            out = self.bn1(out)

        out = self.relu(out)

        out = self.conv2(out)

        if hasattr(self, 'bn2'):
            out = self.bn2(out)

        if self.downsample is not None:
            identity = self.downsample(x)

        out += identity
        out = self.relu(out)

        return out


class Bottleneck(nn.Module):
    expansion = 4

    def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
                 base_width=64, dilation=1, norm_layer=None,deconv=None):
        super(Bottleneck, self).__init__()
        if norm_layer is None:
            norm_layer = nn.BatchNorm2d
        width = int(planes * (base_width / 64.)) * groups
        # Both self.conv2 and self.downsample layers downsample the input when stride != 1
        self.conv1 = conv1x1(inplanes, width,deconv=deconv)
        self.conv2 = conv3x3(width, width, stride, groups, dilation,deconv=deconv)
        self.conv3 = conv1x1(width, planes * self.expansion,deconv=deconv)
        self.relu = nn.ReLU(inplace=True)
        self.downsample = downsample
        self.stride = stride
        if not deconv:
            self.bn1 = norm_layer(width)
            self.bn2 = norm_layer(width)
            self.bn3 = norm_layer(planes * self.expansion)

    def forward(self, x):
        identity = x

        out = self.conv1(x)

        if hasattr(self,'bn1'):
            out = self.bn1(out)

        out = self.relu(out)

        out = self.conv2(out)

        if hasattr(self, 'bn2'):
            out = self.bn2(out)

        out = self.relu(out)

        out = self.conv3(out)

        if hasattr(self, 'bn3'):
            out = self.bn3(out)

        if self.downsample is not None:
            identity = self.downsample(x)

        out += identity
        out = self.relu(out)

        return out


class ResNet(nn.Module):

    def __init__(self, block, layers, num_classes=1000, zero_init_residual=False,
                 groups=1, width_per_group=64, replace_stride_with_dilation=None,
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



