- 使用Pytorch pretrained=True时,IDE下很慢,有时候还会报错。于是点击链接用浏览器下载。
- 这时候才能看到我真实的带宽。下载完后放在哪里呢?
- 顺藤摸瓜:
if pretrained:
state_dict = load_state_dict_from_url(model_urls[arch],
progress=progress)
通过load_state_dict_from_url,继续定位
def load_state_dict_from_url(url, model_dir=None, map_location=None, progress=True, check_hash=False):
r"""Loads the Torch serialized object at the given URL.
If downloaded 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 ``$TORCH_HOME/checkpoints`` where
environment variable ``$TORCH_HOME`` defaults to ``$XDG_CACHE_HOME/torch``.
``$XDG_CACHE_HOME`` follows the X Design Group specification of the Linux
filesytem layout, with a default value ``~/.cache`` if not set.
Example:
>>> state_dict = torch.hub.load_state_dict_from_url('https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth')
后面还有一大堆。。。
于是可以看到 default value of model_dir
is $TORCH_HOME/checkpoints
我使用的Ubuntu,$TORCH_HOME位于home/用户名/ 下,找到 .cache。这是一个隐藏文件,如果没有看到,按下Ctrl+H就可以了。在这里面找到torch文件夹,就可以看到checkpoints了。
总结,位于 /home/你的用户名/.cache/torch/checkpoints
把下载的训练权重.pth文件放到这里面,就可以识别到了!