class BasicBlock(nn.Module):
        # see https://pytorch.org/docs/0.4.0/_modules/torchvision/models/resnet.html
        def __init__(self, inplanes, planes, stride=1):
          super(BasicBlock, self).__init__()
          self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
          self.bn1 = nn.BatchNorm2d(planes)
          self.relu = nn.ReLU(inplace=True)
          self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, padding=1, bias=False)
          self.bn2 = nn.BatchNorm2d(planes)
      
        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 += residual
          out = self.relu(out)
          return out
      Python language logo
      your recipe card header background

      Resnet Basic Block

      Pytorch Public Recipes

      Library: pytorch

      Shortcut: pytorch.layer.resnet.block

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.