博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
TypeError: ufunc ‘true_divide‘ output (typecode ‘d‘) could not be coerced to provided outp
阅读量:4153 次
发布时间:2019-05-25

本文共 590 字,大约阅读时间需要 1 分钟。

深度学习中图片处理经常用到的预处理代码:

……    if mode == 'tf':        x /= 127.5        x -= 1.        if x.ndim == 3:            x = np.expand_dims(x, 0)        return x        if mode == 'custom':        x /= 255        if x.ndim == 3:            x = np.expand_dims(x, 0)        return x        if mode == 'torch':        x /= 255.        mean = [0.485, 0.456, 0.406]        std = [0.229, 0.224, 0.225]

在之前要加一句类型转换,否则会报错:TypeError: ufunc ‘true_divide’ output (typecode ‘d’) could not be coerced to provided output parameter (typecode ‘B’) according to the casting rule ‘‘same_kind’’

x = x.astype(np.float32)

转载地址:http://jarti.baihongyu.com/

你可能感兴趣的文章
【Python】学习笔记——-7.0、面向对象编程
查看>>
【Python】学习笔记——-7.2、访问限制
查看>>
【Python】学习笔记——-7.3、继承和多态
查看>>
【Python】学习笔记——-7.5、实例属性和类属性
查看>>
git中文安装教程
查看>>
虚拟机 CentOS7/RedHat7/OracleLinux7 配置静态IP地址 Ping 物理机和互联网
查看>>
Jackson Tree Model Example
查看>>
常用js收集
查看>>
如何防止sql注入
查看>>
springmvc传值
查看>>
在Eclipse中查看Android源码
查看>>
Android使用webservice客户端实例
查看>>
[转]C语言printf
查看>>
C 语言学习 --设置文本框内容及进制转换
查看>>
C 语言 学习---ComboBox相关、简易“假”管理系统
查看>>
C 语言 学习---回调、时间定时更新程序
查看>>
第十一章 - 直接内存
查看>>
JDBC核心技术 - 上篇
查看>>
一篇搞懂Java反射机制
查看>>
Single Number II --出现一次的数(重)
查看>>