Python FutureWarning:不推荐将issubdtype的第二个参数从'float'转换为'np.floating'
在更新我的Python FutureWarning:不推荐将issubdtype的第二个参数从'float'转换为'np.floating',python,numpy,tensorflow,Python,Numpy,Tensorflow,在更新我的Numpy和Tensorflow之后,我收到了此类警告。我已经试过了,但是没有效果,我会感谢你的每一个建议 FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`. from ._con
Numpy
和Tensorflow
之后,我收到了此类警告。我已经试过了,但是没有效果,我会感谢你的每一个建议
FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
2018-01-19 17:11:38.695932: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
之前我也遇到同样的错误,我只是使用了warnings()模块。我在你所有的导入之后使用了这些代码
import warnings
warnings.filterwarnings('ignore', '.*do not.*',)
我尝试过这些,它为我解决了同样的问题,只是把这些放在你的代码顶部
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"]="3"
您还可以使用以下代码,通过使用代码开头的以下行,从终端上删除警告行 带警告的代码:
将numpy作为np、sys、tensorflow作为tf导入 打印('\n代码的开始…\n')
输出:FutureWarning:不推荐将issubdtype的第二个参数从float转换为np.floating。将来,它将被视为np.float64==np.dtype(float.type)。 from.\u conv导入寄存器\u转换器作为\u寄存器\u转换器
删除警告的代码:代码的开始…
将numpy作为np、sys、tensorflow作为tf导入 对于范围(3)中的i:#添加此for循环。 sys.stdout.write('\033[F')#返回上一行。 sys.stdout.write('\033[K')#清除行。
输出:打印('\n代码的开始…\n')
这可能是您的情况,也可能不是您的情况,但同样的警告也会从代码的开始…
软件包中发出:h5py
: FutureWarning:将issubdtype的第二个参数从转换为/home/user/bin/conda3/lib/python3.6/site packages/h5py/\uuuuuu init\uuuuuuu.py:34
到float
。将来,它将被处理 asnp。不推荐使用float
.from.\u conv导入 将\u转换器注册为\u寄存器\u转换器 对于任何带着这个问题来到这里的人来说,这是一个,介绍了。正如开发人员所说: 你可以忽略这个警告,它不会引起任何问题 现在,但您应该升级到h5py的下一个版本 变得可用 …因此它是无害的。修复程序刚刚发布。但在更新发布之前,解决方法是将numpy降级到以前的版本:np.float64==np.dtype(float).type
更新:pip install numpy==1.13.0
带有修复程序的RC构建。以下命令应执行此操作:h5py
更新(最终版):现在有一个完整的版本。因此,您只需运行:pip install h5py==2.8.0rc1
pip install --upgrade h5py
从此警告中将scipy升级为的rif。为此,您可以使用pip升级scipy**sudo pip install --upgrade scipy**
这是由于h5py和numpy之间存在版本冲突。您只需通过以下命令降级numpy版本:pip install numpy==1.13.0
以上这些在我的情况下都不起作用,我不想降低任何程序包的级别 上有一个简单的解决方案,只需取消显示警告:然后导入导致错误的任何包(import warnings with warnings.catch_warnings(): warnings.filterwarnings("ignore",category=FutureWarning) import numpy as np import tensorflow as tf import h5py as h5py
),在numpy,tensorflow,h5py
语句的范围内,您可以升级h5py
pip install --upgrade h5py
我通过安装/重新安装ipykernel修复了此问题:pip3 install --upgrade ipykernel
当然,如果您有不同的pip,您需要升级h5py,numpy版本应该是,您可能需要首先找出原因(这里的大多数答案适用于特定场景-库使用不推荐的功能-在numpy的情况下) 根本原因 简言之,确实发生了一些事情:而不是:np.issubdtype(某物,浮动)
这是在断言和逻辑分派代码中完成的,终端用户很少编写这些代码。因此,这通常是由您正在使用的库完成的 如何进行 因此,您应该找出导致此警告的原因。您将使用np.issubdtype(某物,np.floating)
模块,但与其他答案相反:警告
这不仅会给你警告,还会给你一个错误和堆栈跟踪。然后-你就是黄金:import warnings warnings.filterwarnings('error') # run rest of your code here
在这里,您可以看到这一次是VTK。这当然不可能是您的具体问题,但在了解引起此警告的原因后,您可以做许多有用的事情:Traceback (most recent call last): File (...) # user code snipped... File "C:\...\site-packages\vtk\util\numpy_support.py", line 137, in numpy_to_vtk assert not numpy.issubdtype(z.dtype, complex), \ File "C:\...\site-packages\numpy\core\numerictypes.py", line 422, in issubdtype FutureWarning, stacklevel=2 FutureWarning: Conversion of the second argument of issubdtype from `complex` to `np.complexfloating` is deprecated. In future, it will be treated as `np.complex128 == np.dtype(complex).type`.
对此有任何更新吗?设法解决了它,我得到了同样的警告是的,请参阅@raja answer
- 在正确的位置使警告静音(就在调用代码之前),然后恢复所有警告
- 查找库的更新版本,该库已修复此问题
- 可能会向有问题的图书馆报告一个问题
- 如果存在问题,但没有修复:编写修复程序并创建拉取请求
- 让世界变得更美好
(比公认的答案更好的解决方案)@Hooked:它实际上是如何修复代码的?好奇地想知道你是如何找到这个解决方案的。感谢所有人说出它发生的原因(并给出一个简单的代码示例),或者只是pip install h5py==2.8.0rc1
和pip安装-U…
再次出现?也许有人想知道这个警告告诉我们什么?作为警告说明,这只会抑制显示的警告,实际上不会解决导致该警告的情况;它只会隐藏它。是的,这是目前的修复方法。我相信随着新库的更新,修复方法将就位,warning将不会被提升。这是一个非常简洁的快速修复方法。感谢您的分享。@ShubhamSharma如果您使用的是tensorflow>=1.5.0和python 3.6,它可能需要numpy 1.13+(请参阅),因此在选择numpy版本时必须小心。目前,1.13.0似乎是最佳选择。如果tensorflow<1.5.0,numpy版本并不重要。我有所有这些框架的最新版本,但它给了我相同的结果warning@ShubhamSharma答案是建议降级numpy,而不是获取最新版本h5py的更新正在进行中可用,请参考ClaudeCOULO导入警告;警告。过滤器警告(“忽略”)
Traceback (most recent call last): File (...) # user code snipped... File "C:\...\site-packages\vtk\util\numpy_support.py", line 137, in numpy_to_vtk assert not numpy.issubdtype(z.dtype, complex), \ File "C:\...\site-packages\numpy\core\numerictypes.py", line 422, in issubdtype FutureWarning, stacklevel=2 FutureWarning: Conversion of the second argument of issubdtype from `complex` to `np.complexfloating` is deprecated. In future, it will be treated as `np.complex128 == np.dtype(complex).type`.