首页 > 解决方案 > 数据类型的张量流警告

问题描述

我在 Python 3.7.4 [64 位] 中安装了 tensorflow 和 numpy。当我尝试导入它时,我收到以下警告:

/home/user/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516:FutureWarning:不推荐将(type,1)或'1type'作为类型的同义词; 在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_qint8 = np.dtype([("qint8", np.int8, 1)]) /home/user/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning:不推荐将 (type, 1) 或 '1type' 作为类型的同义词传递;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_quint8 = np.dtype([("quint8", np.uint8, 1)]) /home/user/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning:不推荐将 (type, 1) 或 '1type' 作为类型的同义词传递;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_qint16 = np.dtype([("qint16", np.int16, 1)]) /home/user/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning:不推荐将 (type, 1) 或 '1type' 作为类型的同义词传递;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_quint16 = np.dtype([("quint16", np.uint16, 1)]) /home/user/.local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning:不推荐将 (type, 1) 或 '1type' 作为类型的同义词传递;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_qint32 = np.dtype([("qint32", np.int32, 1)]) /home/user/. local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:525:FutureWarning:不推荐将 (type, 1) 或 '1type' 作为类型的同义词传递;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。np_resource = np.dtype([("资源", np.ubyte, 1)])

/home/user/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541:FutureWarning:不推荐将(type,1)或'1type'作为类型的同义词传递;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_qint8 = np.dtype([("qint8", np.int8, 1)]) /home/user/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning:不推荐将 (type, 1) 或 '1type' 作为类型的同义词传递;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_quint8 = np.dtype([("quint8", np.uint8, 1)]) /home/user/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: 传递 (type, 1) 或 '1type' 作为类型的同义词已被弃用;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_qint16 = np.dtype([("qint16", np.int16, 1)]) /home/user/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning:不推荐将 (type, 1) 或 '1type' 作为类型的同义词传递;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_quint16 = np.dtype([("quint16", np.uint16, 1)]) /home/user/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning:不推荐将 (type, 1) 或 '1type' 作为类型的同义词传递;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。_np_qint32 = np.dtype([("

我有以下版本- numpy- 1.17.0 tensorflow- 1.14.0

如何解决 tensorflow 中不同数据类型的警告?

谢谢!

标签: pythonnumpytensorflow

解决方案


它的意思是为了符合numpy这条线的计划变化

np_resource = np.dtype([("resource", np.ubyte, 1)])

将需要重写为

np_resource = np.dtype([("resource", np.ubyte, (1,))])

我认为这不在您自己的代码中。

numpy 1.17 中的相关段落是:

https://docs.scipy.org/doc/numpy/release.html#future-changes

这是一个警告,而不是错误。numpy在最近的类似 SO 中,发布者通过切换到早期版本来摆脱它。

“不推荐使用类型的同义词;在 numpy 的未来版本中,它将被理解为 (type, (1,)) / '(1,)type'。” TensorFlow 中的问题


推荐阅读