首页 > 解决方案 > models.vgg16(pretrained=True) 由于 TqdmKeyError:“未知参数:{'unit_divisor': 1024}”

问题描述

我正在尝试运行:models.vgg16(pretrained=True) 并获得 pytorch 的预保留模型,但我得到了一个错误,这个错误之前已经被问过 - 但那里的回答对我没有帮助:/

我尝试升级 tqdm 和 twine 但没有成功。

谢谢..

完整日志:

TqdmKeyError                              Traceback 

(most recent call last)
<ipython-input-13-f93ae0d83650> in <module>
      2 from torchvision import transforms, datasets, models
      3 
----> 4 model = models.vgg16(pretrained=True)
      5 
      6 # n_inputs = model.classifier[6].in_features

c:\users\user\appdata\local\programs\python\python37\lib\site-packages\torchvision\models\vgg.py in vgg16(pretrained, progress, **kwargs)
    148         progress (bool): If True, displays a progress bar of the download to stderr
    149     """
--> 150     return _vgg('vgg16', 'D', False, pretrained, progress, **kwargs)
    151 
    152 

c:\users\user\appdata\local\programs\python\python37\lib\site-packages\torchvision\models\vgg.py in _vgg(arch, cfg, batch_norm, pretrained, progress, **kwargs)
     91     if pretrained:
     92         state_dict = load_state_dict_from_url(model_urls[arch],
---> 93                                               progress=progress)
     94         model.load_state_dict(state_dict)
     95     return model

c:\users\user\appdata\local\programs\python\python37\lib\site-packages\torch\hub.py in load_state_dict_from_url(url, model_dir, map_location, progress, check_hash, file_name)
    553             r = HASH_REGEX.search(filename)  # r is Optional[Match[str]]
    554             hash_prefix = r.group(1) if r else None
--> 555         download_url_to_file(url, cached_file, hash_prefix, progress=progress)
    556 
    557     if _is_legacy_zip_format(cached_file):

c:\users\user\appdata\local\programs\python\python37\lib\site-packages\torch\hub.py in download_url_to_file(url, dst, hash_prefix, progress)
    443             sha256 = hashlib.sha256()
    444         with tqdm(total=file_size, disable=not progress,
--> 445                   unit='B', unit_scale=True, unit_divisor=1024) as pbar:
    446             while True:
    447                 buffer = u.read(8192)

c:\users\user\appdata\local\programs\python\python37\lib\site-packages\tqdm\_tqdm.py in __init__(self, iterable, desc, total, leave, file, ncols, mininterval, maxinterval, miniters, ascii, disable, unit, unit_scale, dynamic_ncols, smoothing, bar_format, initial, position, postfix, gui, **kwargs)

TqdmKeyError: "Unknown argument(s): {'unit_divisor': 1024}"

标签: pythonpytorchtransfer-learningvgg-nettqdm

解决方案


推荐阅读