Shortcuts

torch.hub

torch.hub.load(github, model, force_reload=False, *args, **kwargs)[source]

Load a model from a github repo, with pretrained weights.

Parameters:
  • github – Required, a string with format “repo_owner/repo_name[:tag_name]” with an optional tag/branch. The default branch is master if not specified. Example: ‘pytorch/vision[:hub]’
  • model – Required, a string of entrypoint name defined in repo’s hubconf.py
  • force_reload – Optional, whether to discard the existing cache and force a fresh download. Default is False.
  • *args – Optional, the corresponding args for callable model.
  • **kwargs – Optional, the corresponding kwargs for callable model.
Returns:

a single model with corresponding pretrained weights.

torch.hub.set_dir(d)[source]

Optionally set hub_dir to a local dir to save downloaded models & weights.

If this argument is not set, env variable TORCH_HUB_DIR will be searched first, ~/.torch/hub will be created and used as fallback.

Parameters:d – path to a local folder to save downloaded models & weights.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources