【warning】UserWarning: The parameter ‘pretrained‘ is deprecated since 0.13 and may be removed

这篇具有很好参考价值的文章主要介绍了【warning】UserWarning: The parameter ‘pretrained‘ is deprecated since 0.13 and may be removed。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

import torchvision.models as models
self.backbone = models.resnet101(pretrained=True) #旧版本写法

报错内容:

C:\Users\ting\anaconda3\envs\pytorch\python.exe C:\Users\Administrator\PycharmProjects\FCN\model\fcn_res101.py 
C:\Users\ting\anaconda3\envs\pytorch\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(
C:\Users\ting\anaconda3\envs\pytorch\lib\site-packages\torchvision\models\_utils.py:223: 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=ResNet101_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet101_Weights.DEFAULT` to get the most up-to-date weights.
  warnings.warn(msg)
torch.Size([1, 21, 256, 256])

Process finished with exit code 0

翻译一下,就是参数列表中的pretrained在新版本中被弃了,要使用weights这个参数。然后教你用新的参数。

就按照watning里写的把models.resnet101()后面的内容重新设置就好。


第一种:weights = models.ResNet101_Weights.DEFAULT

userwarning: the parameter 'pretrained' is deprecated since 0.13 and may be,pytorch,bug,深度学习,pytorch,人工智能

import torchvision.models as models
self.backbone = models.resnet101(weights = models.ResNet101_Weights.DEFAULT)

输出结果: 

C:\Users\ting\anaconda3\envs\pytorch\python.exe C:\Users\Administrator\PycharmProjects\FCN\model\fcn_res101.py 
Downloading: "https://download.pytorch.org/models/resnet101-cd907fc2.pth" to C:\Users\Administrator/.cache\torch\hub\checkpoints\resnet101-cd907fc2.pth
100%|██████████| 171M/171M [00:42<00:00, 4.17MB/s]
torch.Size([1, 21, 256, 256])

Process finished with exit code 0

第二种:weights = models.ResNet101_Weights.IMAGENET1K_V1

userwarning: the parameter 'pretrained' is deprecated since 0.13 and may be,pytorch,bug,深度学习,pytorch,人工智能

import torchvision.models as models
self.backbone = models.resnet101(weights = models.ResNet101_Weights.IMAGENET1K_V1)

 输出结果:

C:\Users\ting\anaconda3\envs\pytorch\python.exe C:\Users\Administrator\PycharmProjects\FCN\model\fcn_res101.py 
torch.Size([1, 21, 256, 256])

Process finished with exit code 0

res101中weight官方解释文章来源地址https://www.toymoban.com/news/detail-548676.html

到了这里,关于【warning】UserWarning: The parameter ‘pretrained‘ is deprecated since 0.13 and may be removed的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • UserWarning: __floordiv__is deprecated, and its behavior will change in a future version of pytorch.

    UserWarning: __floordiv__is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the ‘trunc’ function NOT ‘floor’). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode=‘trunc’), or for actual floor division, use torch.div(a,

    2024年02月16日
    浏览(26)
  • [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent..

     错误:[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop\\\'s value. Prop being mutated: \\\"value\\\". 译文:[Vue警告]:避免直接改变prop,因为每当父组件重新呈现时,该值将被覆盖。相反,应该使用基于

    2024年02月12日
    浏览(36)
  • [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c

    报错翻译:避免直接更改一个prop,因为每当父组件重新渲染时,该值都会被覆盖。相反,应使用基于prop值的数据或计算属性。正在更改的prop:“activeId” 解决办法,使用基于prop的值,即把名为activeId的prop的值放在另一个变量中,对那个变量进行修改,不修改activeId。 1、实

    2024年02月03日
    浏览(41)
  • Warning: [antd: Tabs] Tabs.TabPane is deprecated. Please use `items` directly.

    Warning: [antd: Tabs] Tabs.TabPane is deprecated. Please use items directly. 控制台报错 Warning: [antd: Tabs] Tabs.TabPane is deprecated. Please use items directly. https://ant.design/components/tabs/ Usage upgrade after 4.23.0# antd tabs组件 在 4.23.0 版本上做了更新

    2024年02月14日
    浏览(31)
  • warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME

    elasticsearch-7.15.2启动时警告信息: 1 \\\"warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME\\\" 译文的含义是指“警告:不推荐使用JAVA_HOME,请使用ES_JAVA_HOME”。 elasticsearch 7系列版本以上都是自带的jdk,可以在es的bin目录下找到elasticsearch-env.bat这个文件,配置es的jdk。官方推荐使用e

    2024年02月16日
    浏览(41)
  • ElasticSearch--warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME

    es和jdk是一个强依赖的关系,所以当我们在新版本的ElasticSearch压缩包中包含有自带的jdk,但是当我们的Linux中已经安装了jdk之后,就会发现启动es的时候优先去找的是Linux中已经装好的jdk,此时如果jdk的版本不一致,就会造成jdk不能正常运行,报错如下: warning: usage of JAVA_HOM

    2024年02月06日
    浏览(30)
  • [AxiosError]: There is no suitable adapter to dispatch the request since :- adapter xhr is not suppo

    最近在写一个node项目时,webpack打包之后运行打包的js文件报错:  [AxiosError]: There is no suitable adapter to dispatch the request since : - adapter xhr is not supported by the environment - adapter http is not available in the build     at we (C:UserslzzDocuments网盘脚本distbundle.js:2:32230)     at Ce.Se (C:Userslzz

    2024年02月03日
    浏览(41)
  • Warning: Calling formula.plist_path is deprecated. Use formula.launchd_service_path instead.

    Homebrew 的使用之旅 今天在使用 brew services list 指令的时候,输出一直含有警告内容⚠️: 虽然不影响使用,但是却不太“优雅”。 这个警告是因为在 Homebrew 2.6.0 版本中, formula.plist_path 属性已被弃用,替代方法是使用 formula.launchd_service_path 属性。如果你的 Homebrew 版本较旧,

    2023年04月09日
    浏览(31)
  • elasticsearch启动警告的修复方案 warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME“

    最近在搞skywalking,在windows10 上进行skywalking功能初步的验证,部署应用版本信息如下: jdk1.8(windows上的JAVA_HOME)+oap 9.3.0 +es7.11 在环境搭建之前查阅相关资料说明es7要求最低的java版本是 11并且自身携带jdk。 (目录:elasticsearch-7.17.0jdk)es7运行时无需关注系统本身的jdk版本问

    2024年03月18日
    浏览(93)
  • 【Android】The ‘kotlin-android-extensions‘ Gradle plugin is deprecated

    最近跑编译的时候,经常有个警告 意思是说 kotlin-android-extensions 已经废弃了,让我用 kotlin-parcelize 在 build.gradle 中需要如下修改:

    2024年02月11日
    浏览(31)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包