我目前正在关注这个tutorial在第 4 节。当我运行命令来生成 TF 记录时,它会返回generate_tfrecord.py 文件的回溯错误。第一个错误是:
flags = tf.compat.v1.flags
flags.DEFINE_string('csv_input', '', 'Path to the CSV input')
flags.DEFINE_string('image_dir', '', 'Path to the image directory')
flags.DEFINE_string('output_path', '', 'Path to output TFRecord')
FLAGS = flags.FLAGS
我只是通过添加 .compat.v1 行来修复它,因为我使用的是 TF 2.0。
我遇到的下一个错误是最后一行;
if __name__ == '__main__':
tf.app.run()
它返回:
Traceback (most recent call last):
File "generate_tfrecord.py", line 101, in <module>
tf.app.run()
AttributeError: module 'tensorflow' has no attribute 'app'
任何帮助将不胜感激! -干杯
最佳答案
在本 TensorFlow 2 指南中,https://www.tensorflow.org/guide/effective_tf2 ,它说 tf.app
已被删除。
要解决此问题,请卸载 TensorFlow 2.x,然后安装 1.x,或者修改代码以使其使用 2.x API。
您应该能够只调用 main 方法而不是 tf.app.run()。
关于python - 属性错误: module 'tensorflow' has no attribute 'app' : error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59272234/