Python FutureWarning:不推荐将 issubdtype 的第二个参数从 `float` 转换为 `np.floating`

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48340392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:39:39  来源:igfitidea点击:

FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated

pythonnumpytensorflow

提问by Shubham Sharma

After updating my Numpyand TensorflowI am getting these kind of warnings. I had already tried these, but nothing works, every suggestion will be appreciated.

更新我NumpyTensorflow我收到这些警告后。我已经尝试过这些,但没有任何效果,每个建议都会受到赞赏。

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\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

采纳答案by raja

I had tried with these and it had solved same problem for me , just put these at top of your code

我试过这些,它为我解决了同样的问题,只需将这些放在代码的顶部

import os
os.environ["TF_CPP_MIN_LOG_LEVEL"]="3"

回答by Maxim

This might or might not be your case, but the same warning is also spit out from h5pypackage:

这可能是也可能不是你的情况,但同样的警告也会从h5py包中吐出:

/home/user/bin/conda3/lib/python3.6/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from floatto np.floatingis deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters

/home/user/bin/conda3/lib/python3.6/site-packages/h5py/__init__.py:34: FutureWarning:不推荐将 issubdtype 的第二个参数从floatto转换 np.floating。将来,它将被视为np.float64 == np.dtype(float).type. 从 ._conv 导入 register_converters 作为 _register_converters

For anyone coming here with thisproblem, it is a known h5py issue, introduced with numpy 1.14. As stated by the devs:

对于遇到问题的任何人,这是一个已知的 h5py 问题,由numpy 1.14引入。正如开发人员所说:

You can ignore the warning, it's not going to cause any issues at the moment, but you should upgrade to the next release of h5py when it becomes available.

您可以忽略警告,它目前不会导致任何问题,但是您应该在 h5py 可用时升级到下一个版本。

... so it's harmless. The fix has just been mergedto master. But until the update is released, the workaround is to downgrade numpy to a previous version:

......所以它是无害的。该修复程序刚刚合并到 master。但是在更新发布之前,解决方法是将 numpy 降级到以前的版本:

pip install numpy==1.13.0

Update: h5pyhas releasedthe RC build with the fix. The following command should do it:

更新h5py已发布带有修复程序的 RC 版本。以下命令应该这样做:

pip install h5py==2.8.0rc1

Update (FINAL): there's a full-fledged release now. So you can simply run:

更新(最终):现在有一个完整的版本。所以你可以简单地运行:

pip install --upgrade h5py

回答by Claude COULOMBE

You could upgrade h5py

你可以升级h5py

pip install --upgrade h5py

回答by Arindam

You can also use the following code to have the warning lines erased from the terminal by using the following lines at the beginning of your code.

您还可以使用以下代码通过在代码开头使用以下几行来从终端中删除警告行。

Code With warning:

代码警告:

import numpy as np, sys, tensorflow as tf print('\nStart of Code...\n')

import numpy as np, sys, tensorflow as tf print('\nStart of Code...\n')

Output:

输出:

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

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

Start of Code...

Start of Code...

Code with Warning Erased:

已删除警告的代码:

import numpy as np, sys, tensorflow as tf for i in range(3): # Add this for loop. sys.stdout.write('\033[F') # Back to previous line. sys.stdout.write('\033[K') # Clear line.

import numpy as np, sys, tensorflow as tf for i in range(3): # Add this for loop. sys.stdout.write('\033[F') # Back to previous line. sys.stdout.write('\033[K') # Clear line.

print('\nStart of Code...\n')

print('\nStart of Code...\n')

Output:

输出:

Start of Code...

Start of Code...

回答by Taylor Mei

This is due to a version conflict between h5py and numpy. All you need to do is degrade your numpy version through command as below:

这是由于 h5py 和 numpy 之间的版本冲突。您需要做的就是通过以下命令降低您的 numpy 版本:

pip install numpy==1.13.0

回答by dopexxx

None of the above worked in my case and I did not want to downgrade any package.

以上都不适用于我的情况,我不想降级任何软件包。

There is a straightforward solution on Github, just suppress the warning:

Github上有一个简单的解决方案,只需取消警告:

import warnings
with warnings.catch_warnings():
    warnings.filterwarnings("ignore",category=FutureWarning)
    import numpy as np
    import tensorflow as tf
    import h5py as h5py

and then import whatever package causes the error (numpy, tensorflow, h5py) within the scopeof the withstatement

然后在语句的范围内导入导致错误的任何包(numpy, tensorflow, h5pywith

回答by Mohammad Mohsin Reza

Upgrade scipy to rif of from this warning. To do this you may use pip to upgrade scipy.

从此警告升级 scipy 到 rif of。为此,您可以使用 pip 升级 scipy。

**sudo pip install --upgrade scipy**

回答by Harshit Gyan

Previously i was getting same error , i just had used warnings() module . I had used these code after your all imports,

以前我遇到了同样的错误,我只是使用了 warnings() 模块。我在你所有的导入后使用了这些代码,

import warnings
warnings.filterwarnings('ignore', '.*do not.*',)

回答by Arvin Amir

I fixed this issue by installing/reinstalling ipykernel:

我通过安装/重新安装 ipykernel 解决了这个问题:

pip3 install --upgrade ipykernel

If you have different pip of course us that one

如果你有不同的 pip 当然是我们那个

回答by Chandan Gupta

You need to upgrade h5py and numpy version should be <1.17:

您需要升级 h5py 并且 numpy 版本应该 <1.17:

pip install --upgrade h5py
pip install "numpy<1.17"