【问题标题】:Understanding Tensorflow Object-Detection API, kwargs for Checkpoint class, what is `_base_tower_layers_for_heads`?了解 Tensorflow Object-Detection API,Checkpoint 类的 kwargs,什么是`_base_tower_layers_for_heads`?
【发布时间】:2020-07-21 18:22:58
【问题描述】:

目前,我一直在学习如何使用 Tensorflow 的 Object-Detection API。我按照他们的建议使用this notebook 使用自定义数据进行训练的快速入门教程。为了理解代码的每一行,我在“创建模型并恢复权重”部分偶然发现了这段 sn-p 代码。

fake_box_predictor = tf.compat.v2.train.Checkpoint(
    _base_tower_layers_for_heads=detection_model._box_predictor._base_tower_layers_for_heads,
    # _prediction_heads=detection_model._box_predictor._prediction_heads,
    #    (i.e., the classification head that we *will not* restore)
    _box_prediction_head=detection_model._box_predictor._box_prediction_head,
    )

我真的不明白在那个特定的 sn-p 代码中,Checkpoint 类可用的关键字参数是什么。我的问题是;是否有任何文档显示关键字参数列表?或者至少解释一下_base_tower_layers_for_heads_box_prediction_head是什么?

我读过tf.train.Checkpointdocumentation。它说我们可以为构造函数的关键字参数提供modelsoptimizers。我已经熟悉这个类来恢复我的模型的权重,但是,我发现看到 _base_tower_layers_for_heads_box_prediction_head 作为关键字参数是陌生的。

我确实知道对象检测架构中的“头”和不同类型的“头”以及它们与迁移学习的关系,但我不了解的是它们的数据结构的上下文。我怎么知道,这些关键字参数存在?还有其他的吗?如果有人能给我见解或至少告诉我在哪里可以找到我可以阅读以进一步理解它的文档,我将不胜感激。

【问题讨论】:

    标签: python tensorflow tensorflow2.0 object-detection object-detection-api


    【解决方案1】:

    我发现了关于Checkpoint 类的非常有用的信息。它不是来自文档,而是来自教程Training Checkpoints > Loading Mechanism

    这是我目前所理解的:

    1. 关键字参数基本上是保存在我们的检查点文件中的属性的名称。
    2. 传递给该特定关键字参数的变量是我们想用检查点值替换其值的变量,换句话说,我们的模型属性。
    3. 检查点架构必须与我们的模型架构相匹配,才能使这种变量恢复工作。

    如果我们想知道我们的检查点文件中保存了哪些属性,我们可以运行这个命令

    tf.train.list_variables(tf.train.latest_checkpoint('path_to_checkpoint'))
    

    【讨论】:

      猜你喜欢
      • 2020-06-16
      • 2017-12-18
      • 2018-01-28
      • 2018-01-14
      • 1970-01-01
      • 1970-01-01
      • 2019-06-17
      • 2018-07-28
      • 1970-01-01
      相关资源
      最近更新 更多