项目场景:

PyTorch 报错:TypeError: exceptions must derive from BaseException

其实是个低级错误,我个人认为是因为没有找到要运行的载体。


问题描述

在 base_options.py 里面设置 --netG 的参数只能在这几个里面选择:

self.parser.add_argument('--netG', type=str, default='p2hed', choices=['p2hed', 'refineD', 'p2hed_att'], help='selects model to use for netG')

但是在选择 netG 时的代码写成了:

def define_G(input_nc, output_nc, ngf, netG, n_downsample_global=3, n_blocks_global=9, n_local_enhancers=1, n_blocks_local=3, norm='instance', gpu_ids=[]):    norm_layer = get_norm_layer(norm_type=norm)     if netG == 'p2hed':    netG = DDNet_p2hED(input_nc, output_nc, ngf, n_downsample_global, n_blocks_global, norm_layer)elif netG == 'refineDepth':netG = DDNet_RefineDepth(input_nc, output_nc, ngf, n_downsample_global, n_blocks_global, n_local_enhancers, n_blocks_local, norm_layer)elif netG == 'p2h_noatt':        netG = DDNet_p2hed_noatt(input_nc, output_nc, ngf, n_downsample_global, n_blocks_global, n_local_enhancers, n_blocks_local, norm_layer)else:raise('generator not implemented!')#print(netG)if len(gpu_ids) > 0:assert(torch.cuda.is_available())   netG.cuda(gpu_ids[0])netG.apply(weights_init)return netG

原因分析:

注意,没有 ‘rfineD’ 这个选项,所以当运行代码时,程序找不到 netG 该选择那个网络,故而报错。


解决方案:

其实,把上面那个代码里面的  “ elif netG == 'refineDepth': ” 改成 “elif netG == 'refineD':” 就可以了。

PyTorch 报错:TypeError: exceptions must derive from BaseException相关推荐

  1. pycharm安装pytorch报错 提示系列问题 torch 包找不到因为pip版本低,结果升级了pip从19.3到20.2 4又提示高版不支持torch安装

    pycharm安装pytorch报错 提示系列问题  torch 包找不到因为pip版本低,结果升级了pip从19.3到20.2 4又提示高版不支持torch安装 DEPRECATION: The - ...

  2. python创建对象后调用对象的方法,报错TypeError: getName() takes 0 positional arguments but 1 was given

    源码 ## TODO: Create multiple cars and visualize them height = 4 width = 6 world = np.zeros((height, w ...

  3. VUE.JS 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法...

    data里面做了定义 在方法里面进行赋值 用 this.info = repos.data 数据可以请求到,但是会报错 TypeError: Cannot set property 'listgrou ...

  4. pytorch报错Unable to get repr for

    pytorch报错Unable to get repr for 标签出现了-1,2或者其他值,loss计算之后, 报错:CUDA error: device-side assert triggered ...

  5. Python报错TypeError: 'str' object is not callable

    原文:http://blog.sina.com.cn/s/blog_71f3890901017rsh.html Python报错TypeError: 'str' object is not calla ...

  6. python报错 TypeError: an integer is required

    问题描述: 在本地使用socket向NetAssist传送数据的时候,执行python文件后发现报出python 报错TypeError: an integer is required错误 代码: 1 ...

  7. 记录webpack使用问题,使用报错“UnhandledPromiseRejectionWarning,file-loader图片过大,无法加载图片,打包html文件报错TypeError

    记录webpack使用报错 版本号问题 运行npm run build,报错 "UnhandledPromiseRejectionWarning: TypeError: this.getRe ...

  8. Python报错TypeError: ‘User‘ object is not iterable

    Python报错TypeError: 'User' object is not iterable 原因 User对象是不可迭代的,我这里是因为User并不是list,所以是不可迭代的,所以不使用迭代即 ...

  9. [转载]UEditor报错TypeError: me.body is undefined

    本文转载来自: UEditor报错TypeError: me.body is undefined 今天在使用UEditor的setContent的时候报错,报错代码如下 TypeError: me.b ...

最新文章

  1. 企业并不怕尝新 业务变革的技术们
  2. UI自动化新思路-基于RUNTIME的自动化测试设想
  3. java.util.concurrent.CyclicBarrier;
  4. 企业网络推广——企业网络推广中如何解决网站排名提升难题?
  5. 解决Nginx: [error] open() "/usr/local/Nginx/logs/Nginx.pid
  6. 戏说模式-追MM与设计模式 (转载)
  7. 图片效果集合(js、jquery或html5)
  8. Jmeter如何进行http接口测试
  9. android build获取ext,顶级build.gradle文件中的ext属性
  10. 感觉自己没有美术天赋,要不要放弃成为艺术生?
  11. oracle11g安装程序闪退,win10安装oracle11g-client闪退
  12. 无感支付及相应技术规范
  13. myeclipse设置黑色主题
  14. 计算机维护系统管理毕业设计,计算机系统维护-毕业论文.doc
  15. 公司网盘间的风云变幻PK赛
  16. 拆解玩具电池充电器:充久了可能会爆,廉价电路方案让人震惊!
  17. Office Professional Plus 2016简体中文版
  18. html音乐列表在线播放,HTML5 动感的音乐播放列表
  19. keyston api与代码router映射
  20. 7位专家– 7条意见:Java 13的亮点是什么?

热门文章

  1. 使用Xstream_iterator进行文件复制
  2. 中兴通讯:生死危机解除
  3. opencv加法和和numpy加法的比较-04
  4. 使用这款0代码免费报表工具,报表开发可以告别996了
  5. 我的大学生活-5-08-赵心宁
  6. Ubuntu 玩机笔记
  7. 快速提示:如何在JavaScript中创建和处理数组
  8. Xshell 执行python脚本
  9. Intellij IDEA设置中文界面(汉化)
  10. java poi设置单元格格式为数值_java中导出excel设置单元格的样式为数字格式怎么设置_Java代码实现设置单元格格式...