0

I want to get the output of the fc6 layer in the slim vgg16 net, is there any good way to do that?

Actually I have figured out one possible solution, please help me confirm its correctness.

The output of the fc6 layer is actually the result of the Relu op, i.e., the activation function. And I find the name of it is vgg_16/fc6/Relu by executing tf.get_default_graph().get_operations(). So, maybe the result of tf.get_default_graph().get_tensor_by_name('vgg_16/fc6/Relu:0') is what I want?

1 Answer 1

1

From what I have extracted from this Tensorflow code for image segmentation (link) this is how you can extract the output at one layer of a predefined TF-Slim model:

    from tensorflow.contrib.slim import nets

    last_layer_logits, end_points = nets.vgg.vgg_16(img_batch, num_classes=num_classes)

    # examples
    pool4_features = end_points['vgg_16/pool4']
    fc8_features = end_points['vgg_16/fc8']

If you are using another argscope on top of the actual vgg_16 model, you should add it before the vgg_16 argscope:

    fc8_features = end_points['my_great_model_argscope/' + 'vgg_16/fc8']

Hope this helps!

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your solution. Your method does work and so does mine. I didn't know the usage of end_points in TF-Slim model, and the doc on GitHub doesn't mention a single word about it at all!
After playing around for a while with Tensorflow, I have found that TF-Slim is the best solution for me, but yes, lacks a lot of documentation. I have learned a lot from following this IPython notebook (github.com/tensorflow/models/blob/master/slim/…) included in tensorflow/models repository. Good luck with your quest!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.