TensorFlow实现时报错FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated;...

问题如下图:
在这里插入图片描述
出现警告:

FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])

虽然还能实现,但是不能错过任何一个警告。

报错原因:NumPy 的版本太高了,要降级。

解决方法:安装低版本的Numpy

# 卸载旧版本
pip uninstall numpy
# 安装新版本
pip install numpy==版本号

如:

# tensorflow 2.0.0-alpha0 将到1.17.0都不行
pip install numpy==1.16.0

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个警告信息是关于NumPy库的一个即将被弃用的用法。在将来的NumPy版本中,传递`(type, 1)`或`'1type'`会被理解为`(type, (1,))`或`'(1,)type'`。 要解决这个警告,你可以尝试以下几种方法: 1. 更新NumPy库:确保你正在使用最新版本的NumPy库。你可以使用以下命令来更新NumPy: ``` pip install --upgrade numpy ``` 这将会安装最新版本的NumPy库,其中包含对这个警告的修复。 2. 忽略警告:如果你确定代码的其他部分正常工作,你可以选择忽略这个警告。可以通过在代码开头添加以下代码来忽略警告: ```python import warnings warnings.filterwarnings("ignore", category=FutureWarning) ``` 这会将`FutureWarning`类别的警告忽略掉。 3. 修改代码:如果你有直接控制代码的权限,你可以尝试修改代码以避免出现这个警告。具体的修改方式取决于你的代码逻辑和使用到的NumPy函数。一种可能的修改方法是使用`(type, (1,))`代替`(type, 1)`。 例如,如果你有以下代码: ```python _np_qint8 = np.dtype([("qint8", np.int8, 1)]) ``` 你可以将其修改为: ```python _np_qint8 = np.dtype([("qint8", np.int8, (1,))]) ``` 这样就避免了警告。 尝试上述方法后,应该可以解决`FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.`的问题。如果还有其他问题,请告诉我,我将尽力帮助你。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值