liuliu / ccv

C-based/Cached/Core Computer Vision Library, A Modern Computer Vision Library
http://libccv.org
Other
7.08k stars 1.72k forks source link

grab all activations in convolutional/pooling layer #166

Closed genekogan closed 8 years ago

genekogan commented 8 years ago

how do you get all of the activation maps from a convolutional/pooling layer? i understand how encode copies the activations from a fully-connected layer, but in one of the earlier layers where multiple feature maps are activated, how do you grab each one individually?

so for example i set the count of the convnet (AlexNet from imagenet 2012) to 9 for 9th layer.

convnet->count = 9
ccv_dense_matrix_t* input = 0;
ccv_size_t size = ccv_size(225, 225);
ccv_convnet_input_formation(size, &image, &input);
ccv_dense_matrix_t* b = 0;
ccv_convnet_encode(convnet, &input, &b, 1);

b is 13x13 but this must just be just the first one? how would you grab each of them individually?

liuliu commented 8 years ago

It is 13x13xchannel size. The output is a typical ccv_dense_matrix_t layout (think about the RGB image layout).

genekogan commented 8 years ago

right, channel size is always 3 for RGB, but how many individual 3-channel feature maps? for example, in AlexNet, the first convolutional layer produces 96 individual feature maps of 55x55x3. are all of these encoded into b->data.f32? is there a field which counts how many there are for a particular layer?

liuliu commented 8 years ago

CCV_GET_CHANNEL(output->type) Try this. On Tue, Feb 2, 2016 at 10:31 PM Gene Kogan notifications@github.com wrote:

right, channel size is always 3 for RGB, but how many individual 3-channel feature maps? for example, in AlexNet, the first convolutional layer produces 96 individual feature maps of 55x55x3. are all of these encoded into b->data.f32? is there a field which counts how many there are for a particular layer?

— Reply to this email directly or view it on GitHub https://github.com/liuliu/ccv/issues/166#issuecomment-179038608.

genekogan commented 8 years ago

thanks! that worked perfectly. btw this is all for ofxCcv which is a library for wrapping ccv for openframeworks.