使用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
更多咨询咨询请关注!