Feature extraction for a image

Hi I’ve the need to get feature vector of the intermediate layer of pretrained ciphar 10 dataset. However no sample code is available. I came across this documentation
[class gluoncv.nn.feature. FeatureExtractor ( network , outputs , inputs=‘data’ , pretrained=False , ctx=cpu(0) , **kwargs )]

But not sure how to use it.

Can anyone guide me?

Hi @Apoorva_Rani,

You can do this using gluon.nn.SymbolBlock as described here:

Hoping that this will help you

import mxnet as mx

from gluoncv.model_zoo import get_model

net = get_model('cifar_resnet110_v1', classes=10, pretrained=True, root='./model')

#dummy input data

img = mx.nd.random.uniform(shape=(1,3,32,32))

#example1

net_feature_0 = net.features

output1 = net_feature_0(img)

#example2

net_feature_1 = net.features[:-1]

output2 = net_feature_1(img)

#example3

net_feature_2 = net.features[:-2]

output3 = net_feature_2(img)

Is this helpful for you?