python-3.xconv-neural-networkcaffe2

Caffe2 extract fc7 features


recently, I tried to use Convolutional Neural Network(CNN) to extract features of images. The model I used is alexnet, the framework is Caffe2 with Python 3.6.4.

The problem is that I want to extract features of FC7 layer, which should have a dimension of 4096.

How could I manage this issue?


Solution

  • You should use the FetchBlob(blob_name) function of workspace. In your case (assuming that the name of the output of FC7 is 'fc7'):

    blob = workspace.FetchBlob('fc7')
    

    Now, you can easily print the output shape:

    print(blob.shape)