Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Feature maps from network for multiple images all the same

30 views
Skip to first unread message

Martin

unread,
Feb 13, 2018, 10:01:13 AM2/13/18
to Caffe Users
I'm trying to extract the feature maps from a network, similar to what is done here, just for a list of images instead of just one. My code looks something like this:


net = caffe.Net(prototxt, weights, caffe.TEST)
# ...
for img_idx, img_path in enumerate(list_of_image_paths):
    img = caffe.io.load_image(img_path)
    net.blobs['data'].data[...] = transformer.preprocess('data', img)
    net.forward()

    #extract filters and features
    for layer, _ in net.blobs.iteritems():
        if img_idx == 0:
            filters = net.params[l][0].data.copy()
            save_filters(filters, layer) #saves filters for all units
        features = net.blobs[l].data.copy()
        save_features(features, layer, img_idx) #saves featuremaps for all units

This works however the feature maps remain the same for every image. Do I need to somehow reset the network inbetween or how do I accomplish this? 

I've also asked this on Stackoverflow (link)
Reply all
Reply to author
Forward
0 new messages