class_docstr: ResNet with the softmax chopped off and the batchnorm frozen
class_docstr_tok: ["ResNet","with","the","softmax","chopped","off","and","the","batchnorm","frozen"]
code: def __init__(self, input_shape, resnet18=True, resnet_dropout=0.0):
      super(ResNet, self).__init__()
      if resnet18:
          self.network = torchvision.models.resnet18(pretrained=True)
          self.n_outputs = 512
      else:
          self.network = torchvision.models.resnet50(pretrained=True)
          self.n_outputs = 2048
  
      # adapt number of channels
      nc = input_shape[0]
      if nc != 3:
          tmp = self.network.conv1.weight.data.clone()
  
          self.network.conv1 = nn.Conv2d(
              nc,
              64,
              kernel_size=(7, 7),
              stride=(2, 2),
              padding=(3, 3),
              bias=False,
          )
  
          for i in range(nc):
              self.network.conv1.weight.data[:, i, :, :] = tmp[
                  :, i % 3, :, :
              ]
  
      # save memory
      del self.network.fc
      self.network.fc = Identity()
  
      self.freeze_bn()
      self.dropout = nn.Dropout(resnet_dropout)
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  import torchvision.models
label_desc: Use image node_id 1 to create a new ResNet object from inherited base classes: torch.nn with example: obj = ResNet(input_shape, resnet18, resnet_dropout)