tensorflow-1.14 版本更新

使用TensorFlow训练文本筛选,

错误提示:

AttributeError: module 'tensorflow.python.platform.flags' has no attribute 'mark_flag_as_required'

由于使用python3.6,本机安装的TensorFlow是1.2.1版本,得知需要升级1.14才可以解决。

 

所以基于Anaconda平台,进行版本升级,选择使用的enevs 首先open Terminal,进入命令窗口,使用pip安装:

直接使用 pip3 install tensorflow==1.14.0 ,出现443

解决方案:

下载whl文件到本地,https://pypi.tuna.tsinghua.edu.cn/simple/tensorflow/

我这里选择的是 Windows10系统,python3.6版本的 tensorflow-1.14.0rc0-cp36-cp36m-win_amd64.whl

选择国内aliyun镜像源安装,并且加上 --trusted-host

pip install tensorflow-1.14.0rc0-cp36-cp36m-win_amd64.whl -i http://mirrors.aliyun.com/pypi/simple/  --trusted-host  mirrors.aliyun.com


# 或者直接安装

pip install tensorflow==1.14 -i http://mirrors.aliyun.com/pypi/simple/  --trusted-host  mirrors.aliyun.com

至此,更新成功;

再次运行,错误提示

错误提示一: 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)])

pip install numpy==1.16.0 --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple/

错误提示二:

The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.

错误提示三:

could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method Dense.call of <tensorflow.python.layers.core.Dense object at 0x00000135A8C84828>>: AssertionError: Bad argument number for Name: 3, expecting 4

pip install gast==0.2.2 --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple/

错误提示四:

Tensorflow运行中遇到OOM when allocating tensor

解决方法
出现上述原因主要是因为GPU的显存太小,导致程序运行时没有更多的内存支持。

# 1. 指定GPU
# 在程序前两行加入下面的代码:
import os
os.environ["CUDA_VISIBLE_DEVICES"] = '1' #指定第一块GPU可用
# PS:在任务管理器中性能栏查看自己的GPU使用情况,决定具体使用哪块GPU

# 2. 调参
batch_size: 将此参数的值设置小一点;
特征大小:若输入是图片,将图片适当调小

# 3. 使用CPU
import os
os.environ["CUDA_VISIBLE_DEVICES"] = -1
引号里填的是GPU的序号,不填的时候代表不使用GPU

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值