1. Project scenario:
运行tensorflow的代码报错:
Traceback (most recent call last):
File “E:/Pycharm/LotteryPrediction/ssq-master/ssq.py”, line 25, in
tf.app.flags.DEFINE_integer(‘batch_size’, -1, ‘batch size.’)
AttributeError: module ‘tensorflow’ has no attribute ‘app’
2. Reason analysis:
The installed tensorflow is version 2.0, so this error will be reported.
3. Solution:
Modify as follows:
import tensorflow.compat.v1 as tf
FLAGS = tf.app.flags.FLAGS