UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead. warnings.warn(这个问题如何解决
时间: 2024-03-16 10:45:42 浏览: 73
这个问题是由于使用的模型版本较老导致的。解决方法是将代码中的参数`pretrained`替换为`weights`,或者更新模型版本到0.13及以上。同时,建议在代码中加上以下语句以忽略该警告:
```
import warnings
warnings.filterwarnings('ignore')
```
相关问题
C:\Users\PcRobber9th\.conda\envs\env_torchCPU38\lib\site-packages\torchvision\models\_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead. warnings.warn(
这个警告是因为在 torchvision.models 模块中,参数 pretrained 在版本 0.13 中已经被弃用并用 weights 替换。如果你使用的是较新版本的 torchvision,可以使用 weights 参数来代替 pretrained 参数。如果你想继续使用 pretrained 参数,可以通过设置环境变量 TORCHVISION_PRETRAINED_WEIGHTS_WARNING 来消除这个警告。例如:
```python
import os
os.environ['TORCHVISION_PRETRAINED_WEIGHTS_WARNING'] = '1'
```
或者可以尝试更新 torch 和 torchvision,这样就不会出现这个警告了。
UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=ResNet18_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet18_Weights.DEFAULT` to get the most up-to-date weights. warnings.warn(msg)
这个警告信息是关于使用 ResNet18 模型的权重参数的。在版本 0.13 及以后的版本中,使用权重参数时应该只传入一个 weight enum 或者 `None`。如果传入其它参数,则会出现这个警告信息。当前的行为等同于传入 `weights=ResNet18_Weights.IMAGENET1K_V1`。同时,你也可以使用 `weights=ResNet18_Weights.DEFAULT` 来获取最新的权重参数。这个警告信息告诉我们应该遵守最新的 API 使用方式。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)