python - tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) AttributeError: module 'tensorflow' has no attribute 'app'
问题描述
我正在尝试遵循用于 ML 图像分类的诗人指南的张量流。到目前为止,我无法重新训练我的数据集,因为我遇到了以下错误:
Traceback (most recent call last):
File "C:\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\I352778\tensorflow-for-poets-2\tensorflow-for-poets-2\scripts\retrain.py", line 1326, in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
AttributeError: module 'tensorflow' has no attribute 'app'
现在我明白这是由于运行 v1 功能而导致的问题,我正在使用 Tensorflow v2,但仍然不确定我能否解决这个问题。我使用的训练代码如下:
C:\Users\I352778\tensorflow-for-poets-2\tensorflow-for-poets-2>python -m scripts.retrain ^
More? --bottleneck_dir=tf_files/bottlenecks ^
More? --model_dir=tf_files/models/%ARCHITECTURE% ^
More? --summaries_dir=tf_files/training_summaries/%ARCHITECTURE% ^
More? --output_graph=tf_files/retrained_graph.pb ^
More? --output_labels=tf_files/retrained_labels.txt ^
More? --architecture=%ARCHITECTURE% ^
More? --image_dir=tf_files/C:\Users\I352778\Pictures\dataset-resized
我应该如何或输入什么代码来克服我试图实现 v1 功能的事实
解决方案
你能用这个导入吗import tensorflow.compat.v1 as tf
推荐阅读
- python - 使用另一个列表中的格式重新格式化字符串/单词的列表案例
- html - 容器高度等于具有动态高度的重叠子项
- python - 将带有图像数据的 numpy 数组转换为长格式
- javascript - 按下后退按钮时如何取消选择单选按钮?
- c# - 如何对任务同步运行进行单元测试
- excel - 为什么即使使用固定鼠标,MouseMove 事件也会在无模式表单上连续触发?
- android - 我们能否以 95-100 % 的准确度获得设备角度(如指南针)?
- encryption - 凯撒密码:如何加密删除信息的字符?
- database - Postgresql 全文搜索以 hashsign 开头的数字
- gitlab-ci - 如何根据分支名称将 Gitlab 管道复制到目录