composer.models.resnet.model#

A ComposerClassifier wrapper around the torchvision implementations of the ResNet model family.

Classes

ComposerResNet

A ComposerClassifier wrapper around the torchvision implementations of the ResNet model family.

class composer.models.resnet.model.ComposerResNet(model_name, num_classes=1000, pretrained=False, groups=1, width_per_group=64, initializers=None, loss_name='soft_cross_entropy')[source]#

Bases: composer.models.tasks.classification.ComposerClassifier

A ComposerClassifier wrapper around the torchvision implementations of the ResNet model family.

From Deep Residual Learning for Image Recognition (He et al, 2015).

Parameters
  • model_name (str) โ€“ Name of the ResNet model instance. Either ["resnet18", "resnet34", "resnet50", "resnet101", "resnet152"].

  • num_classes (int, optional) โ€“ The number of classes. Needed for classification tasks. Default: 1000.

  • pretrained (bool, optional) โ€“ If True, use ImageNet pretrained weights. Default: False.

  • groups (int, optional) โ€“ Number of filter groups for the 3x3 convolution layer in bottleneck blocks. Default: 1.

  • width_per_group (int, optional) โ€“ Initial width for each convolution group. Width doubles after each stage. Default: 64.

  • initializers (List[Initializer], optional) โ€“ Initializers for the model. None for no initialization. Default: None.

  • loss_name (str, optional) โ€“ Loss function to use. E.g. โ€˜soft_cross_entropyโ€™ or โ€˜binary_cross_entropy_with_logitsโ€™. Loss function must be in loss. Default: 'soft_cross_entropy'โ€.

Example:

from composer.models import ComposerResNet

model = ComposerResNet(model_name='resnet18')  # creates a torchvision resnet18 for image classification