TF版本升级问题集合:成功解决由于不同的TensorFlow版本之间某些函数的用法引起的错误

简介: TF版本升级问题集合:成功解决由于不同的TensorFlow版本之间某些函数的用法引起的错误

遇到的问题以及对应解决方法


Transitioning to TensorFlow 1.0


TensorFlow升级导致的错误,TensorFlow 1.0后与以前代码不兼容,所以要根据API去修改。


参照外文:https://www.tensorflow.org/install/migration



1、解决问题AttributeError: module 'tensorflow' has no attribute 'histogram_summary'


将tf.histogram_summary改为tf.summary.histogram

成功解决AttributeError: module 'tensorflow' has no attribute 'histogram_summary'


2、解决问题AttributeError: module 'tensorflow' has no attribute 'scalar_summary'


将 tf.scalar_summary 改为tf.summary.scalar  


3、解决问题AttributeError: module 'tensorflow' has no attribute 'merge_all_summaries'


将 tf.merge_all_summaries() 改为tf.summary.merge_all()


4、解决问题AttributeError: module 'tensorflow.python.training.training' has no attribute 'SummaryWriter'


将tf.train.SummaryWriter 改为tf.summary.FileWriter


5、解决问题Instructions for updating:  Use `tf.global_variables_initializer` instead.


将tf.initialize_all_variables改为tf.global_variables_initializer


6、解决问题AttributeError: module 'tensorflow.python.ops.nn' has no attribute '_seq2seq'


将tf.nn.seq2seq.sequence_loss_by_example 改为tf.contrib.legacy_seq2seq.sequence_loss_by_example


7、将tf.nn.rnn_cell.改为 tf.contrib.rnn


8、解决问题:AttributeError: module 'tensorflow' has no attribute 'mul'


将tf.mul(input1, input2) 改为 tf.multiply(input1, input2)

TF版本升级问题:解决AttributeError: module 'tensorflow' has no attribute 'mul'


9、解决问题:AttributeError: module 'tensorflow' has no attribute 'sub'


将tf.sub改为tf.subtract


10、解决问题:

tf.merge_all_summaries() 改为 summary_op = tf.summaries.merge_all()


11、解决问题:AttributeError: 'module' object has no attribute 'SummaryWriter'

tf.train.SummaryWriter 改为 tf.summary.FileWriter


12、解决问题:AttributeError: module 'tensorflow.nn.rnn_cell' has no attribute 'linear'

tf.nn.rnn_cell 改为  tf.contrib.rnn.core_rnn_cell



相关文章
|
TensorFlow 算法框架/工具
Tensorflow学习笔记(二):各种tf类型的函数用法集合
这篇文章总结了TensorFlow中各种函数的用法,包括创建张量、设备管理、数据类型转换、随机数生成等基础知识。
587 0
|
Linux TensorFlow 算法框架/工具
安装GPU版本的TensorFlow
【7月更文挑战第3天】安装GPU版本的TensorFlow。
572 1
|
并行计算 TensorFlow 算法框架/工具
Window安装TensorFlow-GPU版本
Window安装TensorFlow-GPU版本
411 0
|
机器学习/深度学习 TensorFlow 算法框架/工具
tensorflow的常用函数
tensorflow的常用函数
132 1
|
TensorFlow 算法框架/工具
【Tensorflow】图解tf.image.extract_patches的用法--提取图片特定区域
文章通过图解和示例详细解释了TensorFlow中tf.image.extract_patches函数的用法,展示了如何使用该函数从图像中提取特定区域或分割图像为多个子图像。
327 0
|
机器学习/深度学习 数据可视化 TensorFlow
Python用线性回归和TensorFlow非线性概率神经网络不同激活函数分析可视化
Python用线性回归和TensorFlow非线性概率神经网络不同激活函数分析可视化
|
机器学习/深度学习 PyTorch TensorFlow
【TensorFlow】TF介绍及代码实践
【4月更文挑战第1天】TF简介及代码示例学习
419 0
|
机器学习/深度学习 人工智能 算法
猫狗宠物识别系统Python+TensorFlow+人工智能+深度学习+卷积网络算法
宠物识别系统使用Python和TensorFlow搭建卷积神经网络,基于37种常见猫狗数据集训练高精度模型,并保存为h5格式。通过Django框架搭建Web平台,用户上传宠物图片即可识别其名称,提供便捷的宠物识别服务。
1022 55
|
机器学习/深度学习 数据采集 数据可视化
TensorFlow,一款由谷歌开发的开源深度学习框架,详细讲解了使用 TensorFlow 构建深度学习模型的步骤
本文介绍了 TensorFlow,一款由谷歌开发的开源深度学习框架,详细讲解了使用 TensorFlow 构建深度学习模型的步骤,包括数据准备、模型定义、损失函数与优化器选择、模型训练与评估、模型保存与部署,并展示了构建全连接神经网络的具体示例。此外,还探讨了 TensorFlow 的高级特性,如自动微分、模型可视化和分布式训练,以及其在未来的发展前景。
1033 5
|
机器学习/深度学习 人工智能 TensorFlow
基于TensorFlow的深度学习模型训练与优化实战
基于TensorFlow的深度学习模型训练与优化实战
573 3