caffe visualization with t-SNE

142 views
Skip to first unread message

Mahfujur Rahman

unread,
Aug 14, 2017, 11:40:01 PM8/14/17
to Caffe Users
I am trying to implement this code. I extracted fc7 features. But I am not sure how to get 4096-dimensional CNN codes for the 50,000 images (as .mat file). Can you help in this regards?

http://cs.stanford.edu/people/karpathy/cnnembed/



Khanh Chuong Le

unread,
Aug 16, 2017, 9:39:47 AM8/16/17
to Caffe Users
Hi there,

AlexNet's fc7 layer has 4096 features (=CNN codes) so all you have to do is to forward propagate all the 50,000 images and for each image store it's CNN code. You will basically get a matrix of the type (50000x4096) and feed this matrix to t-SNE.

If you use other network networks like ResNet then CNN-code is probably conv5_3 with 2048 dimensions (maybe you need to flatten the tensor 1x1x2048 to a vector 2048). And again for all those 50,000 images forward propagate and store their CNN-codes. You will get a matrix of the shape (50000x2048).

Regards
ML

Mahfujur Rahman

unread,
Aug 16, 2017, 10:01:51 PM8/16/17
to Caffe Users
I extracted features using the following command:


./build/tools/extract_features.bin  /models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel examples/_temp/imagenet_val.prototxt fc7  examples/_temp/features 10 leveldb


Am I right ?

Mahfujur Rahman

unread,
Aug 16, 2017, 10:03:42 PM8/16/17
to Caffe Users
In this code they provided one .mat file. How can I create that mat file? The mat file is attached.
imagenet_val_embed.mat
Reply all
Reply to author
Forward
0 new messages