torchvision.models.resnet18(*, weights: Optional[ResNet18_Weights] = None, progress: bool = True, **kwargs: Any) ResNet[source]

ResNet-18 from Deep Residual Learning for Image Recognition.

  • weights (ResNet18_Weights, optional) – The pretrained weights to use. See ResNet18_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool, optional) – If True, displays a progress bar of the download to stderr. Default is True.

  • **kwargs – parameters passed to the torchvision.models.resnet.ResNet base class. Please refer to the source code for more details about this class.

class torchvision.models.ResNet18_Weights(value)[source]

An enumeration.

Examples using ResNet18_Weights:

Torchscript support

Torchscript support

Examples using resnet18:

Torchscript support

Torchscript support


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources