首页 > 解决方案 > Jupyter Notebook 的 TensorFlow 给出“FutureWarning”

问题描述

当我在Jupyter Notebook中运行Tensorflow程序时,我得到了输出以及以下“ FUTUREWARNING ”。我使用以下方法在 Anaconda 中创建了一个 Tensorflow 环境:conda create -n tf tensorflow

我还使用命令初始化了 Tensorflow 环境:conda activate

程序 :

import tensorflow as tf
print ("TensorFlow version: " + tf.__version__) 

输出 :

/home/atishrathour/.local/lib/python3.7/site-packages/tensorflow/python/framework               
/dtypes.py:516: 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)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorflow/python/framework  
/dtypes.py:517: 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_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorflow/python/framework 
/dtypes.py:518: 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_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorflow/python/framework 
/dtypes.py:519: 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_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorflow/python/framework
/dtypes.py:520: 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_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorflow/python/framework
/dtypes.py:525: 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_resource = np.dtype([("resource", np.ubyte, 1)])

TensorFlow 版本:1.14.0

/home/atishrathour/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub 
/dtypes.py:541: 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)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub 
/dtypes.py:542: 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_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub
/dtypes.py:543: 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_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub
/dtypes.py:544: 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_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub
/dtypes.py:545: 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_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/atishrathour/.local/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub
/dtypes.py:550: 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_resource = np.dtype([("resource", np.ubyte, 1)])

标签: tensorflowjupyter-notebookanaconda

解决方案


问题是什么?AFutureWarning不是错误。它警告用户将来会弃用某个功能。

您看到的警告已在 GitHub 上的tensorflow/tensorflow#30427中报告。它们可能是良性的,但如果您想摆脱它们,一个潜在的解决方案是创建或新的 conda 环境并使用 conda 或 pip 重新安装 tensorflow。

所以要么:

conda create --name tf-env tensorflow

或者

conda create --name tf-env python=3.6
conda activate tf-env
pip install --no-cache-dir tensorflow

推荐阅读