在使用TensorFlow导入Mnist数据做数字识别训练时,若先导入tensorflow_core.examples.tutorials.mnist,后导入tensorflow,会出现tensorflow中不存在placeholder的报错信息。
tensorflow版本为1.15
AttributeError: module ‘tensorflow‘ has no attribute ‘placeholder‘
解决方法有两个:
1、直接将import tensorflow as tf 放到第一行,解决!
2、不改变顺序,使用import tensorflow.compat.v1 as tf,解决!