vlfeat / matconvnet

MatConvNet: CNNs for MATLAB
Other
1.4k stars 752 forks source link

extracting features from the last convolutional layer #569

Open hellorp1990 opened 8 years ago

hellorp1990 commented 8 years ago

Hello, I am new to deep neural network. I have started using matconvnet. I am using vgg-f pre-trained network for extracting features. This architecture has 5 convolutional layer and followed by 3 fully connected layer. How can i extract features after the last convolutional layer.

hellorp1990 commented 8 years ago

i can extract pre and post rely features from vgg-f but a little bit confused about extracting features from last convolutional layer.

lyltencent commented 8 years ago

You can use the vl_simplenn function to extract features.

res = vl_simpelnn(net, im_test); featureVector = res(layer_number).x; featureVector = featureVector (:);

hellorp1990 commented 8 years ago

yea I have done this. But egg-f architecture has 8 layers and when I have used vl_simplenn function it is coming 22 output. So thats why couldn't understand which one will be the output of last convolutional layer.

ectg commented 8 years ago

I have a related issue while extracting features from imagenet-caffe-alex.mat. The result from layer 'fc7' after I run my test image of size 500x500x3 is of dimension 10x10x4096,

res = vlsimplenn(alexNet, im) ; layer_number = 18; %'fc7' featureVector = res(layer_number).x;

Shouldn't the featureVector be a 4096x1 vector? Where does the 10x10 patch come from?

lyltencent commented 8 years ago

@ectg , @hellorp1990 ,

When I use the pretrained neural network (http://www.vlfeat.org/matconvnet/models/imagenet-caffe-ref.svg). I use the 20th layer of the res variable for feature extraction. res = vlsimplenn(net, im) ; featVec = res(20).x; featVec = featVec(:);

ectg commented 8 years ago

Hi lyltencent, What is the size of your featVec?

lyltencent commented 8 years ago

@ectg , the size of featVec after those operations is 4096*1.

micklexqg commented 7 years ago

@lyltencent , in res = vlsimplenn(net, im) ; is it a picture read? load('D:\data\datasets\MNIST\test_data.mat') a=images(:,:,1); a=single(a); res = vlsimplenn(net, a); the above is my code, but it failed, so what is the im?

h612 commented 7 years ago

@ectg The activations that reach to the 'fc7' layers are 3x3. You can add stride or remove paddings to ensure the last featurevector size is what u r looking for. Check the size size(net.vars(layerindex).value)