如何知道 Tensorflow Slim 图像模型的每一层名称?



我将从以下提供的预训练模型中微调一些图像模型: https://github.com/tensorflow/models/tree/master/research/slim

以下是微调脚本的模板:

$ DATASET_DIR=/tmp/flowers
$ TRAIN_DIR=/tmp/flowers-models/inception_v3
$ CHECKPOINT_PATH=/tmp/my_checkpoints/inception_v3.ckpt
$ python train_image_classifier.py 
--train_dir=${TRAIN_DIR} 
--dataset_dir=${DATASET_DIR} 
--dataset_name=flowers 
--dataset_split_name=train 
--model_name=inception_v3 
--checkpoint_path=${CHECKPOINT_PATH} 
# Please notice the 2 lines below
--checkpoint_exclude_scopes=InceptionV3/Logits,InceptionV3/AuxLogits  
--trainable_scopes=InceptionV3/Logits,InceptionV3/AuxLogits

最后 2 行是我们想要微调的层,上面的例子仅适用于 Inception 模型。

我想知道我们怎么知道像InceptionV3/Logits这样的层的确切名称?如果我对 ResNet 进行微调,我应该在模板中输入哪个名称?有没有一种正式的方法来获取网络图,以便知道所有的层名称?

当你用slim加载模型时,你应该有两个变量:网络的输出张量和网络组件的字典(这就是你正在寻找的(

这是一个简单的演示代码:

input_image = tf.placeholder('float32', [batch_size, image_size, image_size, 3])
net, end_points = inception.inception_v3(input_image)

最新更新