Python TensorFlow:当我们微调预先训练好的模型的某些层时,是否排除了范围或操作?

Python TensorFlow:当我们微调预先训练好的模型的某些层时,是否排除了范围或操作?,python,machine-learning,tensorflow,deep-learning,tf-slim,Python,Machine Learning,Tensorflow,Deep Learning,Tf Slim,当我指的是网络的一层时,我对范围或操作的含义感到非常困惑。如果我想微调网络的最后一个softmax层,我是要转到作用域、操作还是变量来处理它?所有这些术语之间有什么区别 我已经看过TF slim演练ipynb教程,下面是他们如何排除一些微调范围的: def get_init_fn(): """Returns a function run by the chief worker to warm-start the training.""" checkpoint_exclude_sc

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

我已经看过TF slim演练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\u to\u restore
。可以安全地说范围实际上是指层吗

如果是这样,这就是令人困惑的部分:变量与op的相关性是什么?我的印象是,op.name用于查找作用域名称,如
[“InceptionV1/Logits”,“InceptionV1/AuxLogits”]
,例如,通过编写
[op.name for op in g.get\u operations()]
。如果是这样,为什么变量仍然有
op.name

如何找到范围名称来选择要微调的特定层?我认为这对消除我的困惑非常重要

谢谢大家的帮助