class Bottleneck(nn.Module):
        # see https://pytorch.org/docs/0.4.0/_modules/torchvision/models/resnet.html 
        def __init__(self, inplanes, planes, stride=1, downsample=None):
          super(Bottleneck, self).__init__()
          self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, stride=stride, bias=False)
          self.bn1 = nn.BatchNorm2d(planes)
          self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=1, padding=1, bias=False)
          self.bn2 = nn.BatchNorm2d(planes)
          self.conv3 = nn.Conv2d(planes, planes * 4, kernel_size=1, bias=False)
          self.bn3 = nn.BatchNorm2d(planes * 4)
          self.relu = nn.ReLU(inplace=True)
      
        def forward(self, x):
          residual = x
          out = self.conv1(x)
          out = self.bn1(out)
          out = self.relu(out)
          out = self.conv2(out)
          out = self.bn2(out)
          out = self.relu(out)
          out = self.conv3(out)
          out = self.bn3(out)
          out += residual
          out = self.relu(out)
          return out
      Python language logo
      your recipe card header background

      Resnet Bottleneck Block

      Pytorch Public Recipes

      Library: pytorch

      Shortcut: pytorch.layer.resnet.bottleneck

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.