I would like to obtain the output of the 6th layer of a pre-built caffe model and train an SVM on top of it. My intention is to build a custom image classifier, where the user can create custom image classes, and classify input images among those classes, instead of the imagenet classes.Here is the pseudo code:
#input
file='cat.jpg'
image=caffe.io.load_image(file)
#model
net = caffe.Classifier('deploy.prototxt','model.caffemodel')
#compute activation at layer 6 --- Need help here. Will net.forward help? will the activation be retained?
#extract features from layer 6:
features = net.blobs['fc6'].data[4][:,0, 0]
#SVM
category=svm.predict(features)
print get_category_name(category)