1,No module named "tensorflow.examples"
原因:
TensorFlow包下缺少tutorials文件夹
解决方法:
- 使用命令找到tensorflow的路径
import tensorflow as tf print(tf._ _path_ _)
2.参照一下链接
2,AttributeError: module 'tensorflow' has no attribute 'log'
If you can find the exact line where tf.log
is used, try tf.math.log
instead.
3,ModuleNotFoundError: No module named 'tensorflow.contrib'
在tensorflow2.0版本中可以直接去掉如下代码,在2.0版本中会自动开启
import tensorflow.contrib.eager as tfe
tfe.enable_eager_execution()
4,AttributeError: module 'tensorflow' has no attribute 'layers'
将如下代码:
tf.layers.conv2d()
转换为如下代码:
tf.compat.v1.layers.conv2d()
5,AttributeError: module 'tensorflow._api.v2.train' has no attribute 'AdamOptimizer'
将如下代码:
tf.train.AdamOptimizer()
转变为如下代码:
tf.optimizers.Adam()
6,TypeError: minimize() missing 1 required positional argument: 'var_list'
值得思考
7,AttributeError: module 'tensorflow' has no attribute 'get_variable'
将下列代码
tf.get_variable()
转换为
tf.compat.v1.get_variable()