File "F:\python\python big\yolo\venv\Lib\site-packages\torch\nn\modules\module.py", line 1614, in __getattr__ raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
时间: 2023-06-21 20:12:15 浏览: 539
这个错误可能是因为您正在使用的 PyTorch 版本不兼容 Upsample 模块的 recompute_scale_factor 属性。这个属性是在 PyTorch 1.5 版本中引入的。如果您的 PyTorch 版本低于 1.5,那么您需要升级 PyTorch 到最新版本。
如果您已经使用了 PyTorch 1.5 或更高版本,那么可能是因为您的代码中的 Upsample 模块对象没有被正确地初始化。请确保您使用的 Upsample 模块对象是从 torch.nn.functional.interpolate() 函数中创建的,并且您已经正确地指定了 scale_factor 参数。
如果您仍然无法解决这个问题,请提供更多的代码和上下文,以便更好地帮助您解决问题。
相关问题
RuntimeError: Could not export Python function call 'F'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to __constants__: E:\bolang\yolov7-coupling\utils\activations.py(65): forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(860): _slow_forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(887): _call_impl E:\bolang\yolov7-coupling\models\common.py(112): fuseforward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(860): _slow_forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(887): _call_impl E:\bolang\yolov7-coupling\models\yolo.py(744): forward_once E:\bolang\yolov7-coupling\models\yolo.py(707): forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(860): _slow_forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(887): _call_impl E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\jit\_trace.py(934): trace_module E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\jit\_trace.py(733): trace E:\bolang\yolov7-coupling\utils\torch_utils.py(363): __init__ E:\bolang\yolov7-coupling\detect.py(39): detect E:\bolang\yolov7-coupling\detect.py(196): <module>
这个错误是由于在导出模型时出现了问题。错误信息中提到了一个名为'F'的 Python 函数调用,但没有添加 `@script` 或 `@script_method` 注释。如果这是一个 `nn.ModuleList`,请将其添加到 `__constants__` 中。请检查您的代码中与这些部分相关的部分,并确保按照 PyTorch 的导出要求进行操作。
Traceback (most recent call last): File "mytrain.py", line 640, in <module> main(opt) File "mytrain.py", line 497, in main d = torch.load(last, map_location='cpu')['opt'] File "C:\Users\nb\anaconda3\envs\yolo\lib\site-packages\torch\serialization.py", line 581, in load with _open_file_like(f, 'rb') as opened_file: File "C:\Users\nb\anaconda3\envs\yolo\lib\site-packages\torch\serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "C:\Users\nb\anaconda3\envs\yolo\lib\site-packages\torch\serialization.py", line 211, in __init__ super(_open_file, self).__init__(open(name, mode)) PermissionError: [Errno 13] Permission denied: '.'
这是一个关于Python程序运行时访问权限的错误,提示在当前目录的"."无法获得访问权限。可能需要检查程序文件的读写权限或运行程序的用户是否具有足够的权限。建议您检查程序中与文件访问相关的部分或者尝试在其他目录下运行程序,看看是否能够成功运行。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![whl](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)