zoukankan      html  css  js  c++  java
  • 去除警告: FutureWarning: In future, it will be treated as `np.float64 == np.dtype(float).type`.

    文章目录:
    一、警告原因分析
    二、解决方法
    最近在使用tensorflow-gpu的时候总是报警告,就我这强迫症能够忍他吗,no!绝对不能忍!!!
    我的环境:

    cudnn=7.0
    cuda=9.0
    tensorflow-gpu=1.8 或 1.9 或 1.10.0 或 1.11.0
    在上面的这个环境配置下都会报这个警告,解决方式都是一样的

    一、警告原因分析
    从下面包的警告可以看出,是和h5py这个库包有关的

    import tensorflow as tf
    /home/mosheng/miniconda3/envs/swap_back/lib/python3.5/site-packages/h5py/init.py:36: FutureWarning: Conversion of the secoecated. In future, it will be treated as np.float64 == np.dtype(float).type.
    from ._conv import register_converters as _register_converters

    tf.path
    ['/home/mosheng/miniconda3/envs/swap_back/lib/python3.5/site-packages/tensorflow']

    exit()
    1
    2
    3
    4
    5
    6
    于是查看一下自己本机目前安装的h5py的版本,是h5py=2.7.1

    (swap) mosheng@server:~/miniconda3/envs/swap/lib$ conda list h5py

    packages in environment at /home/mosheng/miniconda3/envs/swap:

    Name Version Build Channel

    h5py 2.7.1
    1
    2
    3
    4
    5
    如果你导入keras也会报同样的错误,因为keras是以tensorflow为后端的。

    import keras
    /home/mosheng/miniconda3/envs/swap/lib/python3.5/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second ard. In future, it will be treated as np.float64 == np.dtype(float).type.
    from ._conv import register_converters as _register_converters
    Using TensorFlow backend.
    1
    2
    3
    4
    二、解决方法
    这个问题是由于h5py的版本造成的,升级一下h5py的版本即可解决
    (我是从2.7.1升级到2.8.0版本,成功去除警告)

    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple h5py==2.8.0
    1
    注意:

    可能会有些人升级是用:pip install h5py==2.8.0rc1
    我试了,这种方法会出现找不到该版本,如若出现上面情况,请去掉版本号后面的rc1即可。

    (swap) mosheng@server:~/miniconda3/envs/swap/lib$ pip install -i https://pypi.tuna.tsinghua.e du.cn/simple h5py2.8.0rc1
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    Collecting h5py
    2.8.0rc1
    Could not find a version that satisfies the requirement h5py2.8.0rc1 (from versions: 2.2. 1, 2.3.0, 2.3.1, 2.4.0, 2.5.0, 2.6.0, 2.7.0, 2.7.1, 2.8.0, 2.9.0)
    No matching distribution found for h5py
    2.8.0rc1
    1
    2
    3
    4
    5
    下面再导入tensorflow 或 keras就不会出现警告啦

    import keras
    Using TensorFlow backend.

    import tensorflow as tf

  • 相关阅读:
    swift 上的 lazy
    oc runtime
    iOS布局
    ios微信支付 v3
    好用的工具
    自己曾经没注意的东西
    根据文字计算出label的高度
    项目swift的一些问题
    UIAppearance
    书签
  • 原文地址:https://www.cnblogs.com/enumx/p/12340042.html
Copyright © 2011-2022 走看看