python - Tensorflow 2.0 中已弃用标志,最好的替代方案是什么?

标签 python tensorflow tensorflow2.0 absl-py

tf.app.flagstf.app.run Tensorflow 1 中的内容已从 Tensorflow 2 中删除。有没有比使用 tf.compat.v1.flags 更好的替代方案?鉴于我是从头开始编写脚本。

最好的方法是什么?我应该坚持 argparse并运行main()

最佳答案

建议使用 abseil-py 而不是 tf.app.flags 。 举个例子,

from absl import app
from absl import flags
from absl import logging

FLAGS = flags.FLAGS

flags.DEFINE_string('flag', None, 'Text')

def main(argv):
  logging.info('flag is %s.', FLAGS.flag)

if __name__ == '__main__':
  app.run(main)

关于python - Tensorflow 2.0 中已弃用标志,最好的替代方案是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69285680/

相关文章:

python-3.x - 遇到以下问题 : build_tensor_flow is not supported in Eager Mode

python - 按一列分组并在 Pandas 中找到另一列的总和和最大值

python - 如何在 SQLAlchemy 中编写生成更新

python - 使用 fastT5 将 T5 模型导出到 onnx 时,得到 "RuntimeError:output with shape [5, 8, 1, 2] doesn' t 匹配广播形状 [5, 8, 2, 2]"

python - 张量转换请求 dtype int32 为 dtype int64 的张量 - while estimator.export_savedmodel

numpy - 带有字符串输入的 Tensorflow 数据集不保留数据类型

python-3.x - 在Tensorflow中获取数据集的长度

python - 计算 github 拉取请求文件中的总行数

python - 我正在尝试使用 selenium 和 python 单击每个链接

python - 在 tensorflow 中找到两个边界框的交集?