file is a zip file, it will be automatically decompressed.

If the object is already present in  model_dir  , it’s deserialized and
returned. The default value of  model_dir  is ` <hub_dir>/checkpoints  ` where
hub_dir  is the directory returned by [ ` get_dir()  `
](hub.html#torch.hub.get_dir "torch.hub.get_dir") .

Parameters

    

  * **url** ( _string_ ) – URL of the object to download 

  * **model_dir** ( _string_ _,_ _optional_ ) – directory in which to save the object 

  * **map_location** ( _optional_ ) – a function or a dict specifying how to remap storage locations (see torch.load) 

  * **progress** ( [ _bool_ ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.8\)") _,_ _optional_ ) – whether or not to display a progress bar to stderr. Default: True 

  * **check_hash** ( [ _bool_ ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.8\)") _,_ _optional_ ) – If True, the filename part of the URL should follow the naming convention ` filename-<sha256>.ext  ` where ` <sha256> ` is the first eight or more digits of the SHA256 hash of the contents of the file. The hash is used to ensure unique names and to verify the contents of the file. Default: False 

  * **file_name** ( _string_ _,_ _optional_ ) – name for the downloaded file. Filename from  url  will be used if not set. 

Example

    
    
    >>> state_dict = torch.hub.load_state_dict_from_url('https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth')
    

[ Next ![](_static/images/chevron-right-orange.svg) ](tensorboard.html
"torch.utils.tensorboard") [ ![](_static/images/chevron-right-orange.svg)
Previous ](mobile_optimizer.html "torch.utils.mobile_optimizer")

* * *

© Copyright 2019, Torch Contributors.

Built with [ Sphinx ](http://sphinx-doc.org/) using a [ theme
](https://github.com/rtfd/sphinx_rtd_theme) provided by [ Read the Docs
](https://readthedocs.org) .

  * torch.utils.model_zoo 

![](https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&guid=ON&script=0)

##  Docs

Access comprehensive developer documentation for PyTorch

[ View Docs ](https://pytorch.org/docs/stable/index.html)

##  Tutorials

Get in-depth tutorials for beginners and advanced developers

[ View Tutorials ](https://pytorch.org/tutorials)

##  Resources

Find development resources and get your questions answered

[ View Resources ](https://pytorch.org/resources)

[ ](https://pytorch.org/)

  * [ PyTorch ](https://pytorch.org/)
  * [ Get Started ](https://pytorch.org/get-started)
  * [ Features ](https://pytorch.org/features)
  * [ Ecosystem ](https://pytorch.org/ecosystem)
  * [ Blog ](https://pytorch.org/blog/)
  * [ Contributing ](https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md)

  * [ Resources ](https://pytorch.org/resources)
  * [ Tutorials ](https://pytorch.org/tutorials)
  * [ Docs ](https://pytorch.org/docs/stable/index.html)
  * [ Discuss ](https://discuss.pytorch.org)
  * [ Github Issues ](https://github.com/pytorch/pytorch/issues)
  * [ Brand Guidelines ](https://pytorch.org/assets/brand-guidelines/PyTorch-Brand-Guidelines.pdf)

  * Stay Connected 
  * Email Address 

[ ](https://www.facebook.com/pytorch) [ ](https://twitter.com/pytorch) [
](https://www.youtube.com/pytorch)

To analyze traffic and optimize your experience, we serve cookies on this
site. By clicking or navigating, you agree to allow our usage of cookies. As
the current maintainers of this site, Facebook’s Cookies Policy applies. Learn
more, including about available controls: [ Cookies Policy
](https://www.facebook.com/policies/cookies/) .

![](_static/images/pytorch-x.svg)

[ ](https://pytorch.org/)

  * [ Get Started ](https://pytorch.org/get-started)
  * [ Features ](https://pytorch.org/features)
  * [ Ecosystem ](https://pytorch.org/ecosystem)
  * [ Mobile ](https://pytorch.org/mobile)
  * [ PyTorch Hub ](https://pytorch.org/hub)
  * [ Blog ](https://pytorch.org/blog/)
  * [ Tutorials ](https://pytorc