ResNet
DD-Ranking supports implementation of ResNet in both DC and torchvision.
We provide the following interface to initialize a ConvNet model:
dd_ranking.utils.get_resnet(model_name: str, im_size: tuple, channel: int, num_classes: int, depth: int, batchnorm: bool, use_torchvision: bool, pretrained: bool, model_path: str) [SOURCE]
Parameters
- model_name(str): Name of the model. Please navigate to models for the model naming convention in DD-Ranking.
- im_size(tuple): Image size.
- channel(int): Number of channels of the input image.
- num_classes(int): Number of classes.
- depth(int): Depth of the network.
- batchnorm(bool): Whether to use batch normalization.
- use_torchvision(bool): Whether to use torchvision to initialize the model. When using torchvision, the ResNet model uses batch normalization by default.
- pretrained(bool): Whether to load pretrained weights.
- model_path(str): Path to the pretrained model weights.
NOTE
When using torchvision ResNet on image size smaller than 224 x 224, we make the following modifications:
model.conv1 = torch.nn.Conv2d(3, 64, kernel_size=(3,3), stride=(1,1), padding=(1,1), bias=False)
model.maxpool = torch.nn.Identity()