栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

TensorFlow遇到的各种错误

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

TensorFlow遇到的各种错误

目录

版本问题

ImportError: cannot import name 'set_random_seed' from 'tensorflow' 

module ‘tensorflow’ has no attribute ‘ConfigProto’/'Session’

`set_session` is not available when using TensorFlow 2.0

OP_REQUIRES failed at save_restore_v2_ops.cc:109 : Not found: Failed to create a NewWriteableFile:


版本问题

很多报错都是因为版本问题,TensorFlow的版本、CUDA的版本等等。比如以下的例子:

ImportError: Could not find 'cudart64_100.dll'

需要下载对应CUDA版本。

或者去网上下载cudart64_100.dll,拷贝到

C:Program FilesNVIDIA GPU Computing ToolkitCUDA10.1Developmentbin目录下

ImportError: cannot import name 'set_random_seed' from 'tensorflow' 

TensorFlow-GPU2.0中遇到这个问题

2.0中的新写法:

import tensorflow
tensorflow.random.set_seed(x)

module ‘tensorflow’ has no attribute ‘ConfigProto’/'Session’

tensorflow2.0版本与之前版本有所更新,故将上述代码改成之下即可:

    #原版 config = tf.ConfigProto(allow_soft_placement=True)
    config = tf.compat.v1.ConfigProto(allow_soft_placement=True)
    #原版 sess = tf.Session(config=config)
    sess =tf.compat.v1.Session(config=config)  #注意 ,这里为tensorflow2.0版本,与第1.0有差距。

`set_session` is not available when using TensorFlow 2.0

若是遇到如题错误,则将

keras.backend.tensorflow_backend.set_session(tf.compat.v1.Session(config=config))

改为

tf.compat.v1.keras.backend.set_session(tf.compat.v1.Session(config=config))

OP_REQUIRES failed at save_restore_v2_ops.cc:109 : Not found: Failed to create a NewWriteableFile:

路径写法问题,错误写法

root_path = "../results/"

正确写法

root_path = "..\results\"

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/942988.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号