2

当我提到网络的一层时,我对范围或操作的含义感到非常困惑。如果我想微调网络的最后一个 softmax 层,我应该去作用域、操作还是变量来处理它?所有这些术语之间有什么区别?

我看过 TF-slim walkthrough ipynb 教程,这里是他们如何排除一些微调范围:

def get_init_fn():
    """Returns a function run by the chief worker to warm-start the training."""
    checkpoint_exclude_scopes=["InceptionV1/Logits", "InceptionV1/AuxLogits"]

    exclusions = [scope.strip() for scope in checkpoint_exclude_scopes]

    variables_to_restore = []
    for var in slim.get_model_variables():
        excluded = False
        for exclusion in exclusions:
            if var.op.name.startswith(exclusion):
                excluded = True
                break
        if not excluded:
            variables_to_restore.append(var)

    return slim.assign_from_checkpoint_fn(
      os.path.join(checkpoints_dir, 'inception_v1.ckpt'),
      variables_to_restore)

似乎他们排除了某些范围["InceptionV1/Logits", "InceptionV1/AuxLogits"],从这些范围中排除了他们想要排除的范围中的每个变量,并包含了他们没有列出的范围中的任何变量variable_to_restore。可以肯定地说范围实际上是指层吗?

如果是这样,这是令人困惑的部分:变量与操作的相关性是什么?我的印象是 op.name 用于查找 scope_name ["InceptionV1/Logits", "InceptionV1/AuxLogits"],例如,通过编写[op.name for op in g.get_operations()]。如果是这样,为什么变量仍然有一个op.name

应该如何找到范围名称来选择某些层进行微调?我认为这对于消除我的困惑非常重要。

谢谢大家的帮助。

4

0 回答 0