tensorflow出现问题Passing (type, 1) or 1type as a synonym of type is deprecated

使用tensorflow时出现Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will…

这个是由于numpy版本与tensorflow版本不匹配导致,虽然不影响使用,但是还是会有强迫症。这里给出两种解决方法:
1、降级numpy版本到1.17.0之下,1.16包含及以下版本不受影响,pip install numpy==1.16.8;(但是这么做并不能体验新版numpy啊,比较以后还更新)
2、此方法需要一定的动手能力,或者操作前先保存副本以免最后tensorflow出问题:
找到…/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py这个文件,这里忽略python3.6,不同版本python这个目录不同;打开dtype.py文件,大约在526行:

_np_qint8 = np.dtype([("qint8", np.int8, 1)])
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
_np_qint32 = np.dtype([("qint32", np.int32, 1)])


# _np_bfloat16 is defined by a module import.

# Custom struct dtype for directly-fed ResourceHandles of supported type(s).
np_resource = np.dtype([("resource", np.ubyte, 1)])

替换为

_np_qint8 = np.dtype([("qint8", np.int8, (1,))])
_np_quint8 = np.dtype([("quint8", np.uint8, (1,))])
_np_qint16 = np.dtype([("qint16", np.int16, (1,))])
_np_quint16 = np.dtype([("quint16", np.uint16, (1,))])
_np_qint32 = np.dtype([("qint32", np.int32, (1,))])

# _np_bfloat16 is defined by a module import.

# Custom struct dtype for directly-fed ResourceHandles of supported type(s).
np_resource = np.dtype([("resource", np.ubyte, (1,))])

然后保存,对…/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py下相同操作,改动的位置差不多也在500多行左右,保存好之后及时numpy高版本也不会受影响。

我叫谢琛,深度学习探索者一枚!(有意咨询xiec177)
tensorflow/pytorch交流群请加QQ:548368797
更多咨询咨询请关注!在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

谢陈(xiec177)

致力于解决深度学习框架问题。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值