《Tensorflow+Keras深度学习人工智能实践应用》的坑们

1、安装时注意版本兼容问题!!!!
tensorflow、keras、python版本兼容问题
https://docs.floydhub.com/guides/environments/
《Tensorflow+Keras深度学习人工智能实践应用》的坑们_第1张图片
2、查看版本时
version前后是两条横线(天坑)
区别:
tf._ version _
tf.__ version __
3、代码show_train_history(train_history, ‘accuracy’, ‘val_accuracy’)
由于版本问题。acc,val_acc是不对的,补全即可
4、AttributeError: module ‘tensorflow’ has no attribute 'Session’错误解决
因为在新的Tensorflow 2.0版本中已经移除了Session这一模块,改换运行代码

tf.compat.v1.Session()
init = tf.compat.v1.global_variables_initializer()

5、RuntimeError: The Session graph is empty. Add operations to the graph before calling run().解决方法
问题产生的原因:无法执行sess.run()的原因是tensorflow版本不同导致的,tensorflow版本2.0无法兼容版本1.0.
解决办法:加上一行代码

tf.compat.v1.disable_eager_execution()

6、AttributeError: module ‘tensorflow’ has no attribute 'Session’错误解决

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

你可能感兴趣的:(机器学习,tensorflow,python,深度学习,机器学习)