我正在尝试从网络中提取特征地图,类似于所做的here,只是为了一个图像列表而不是一个。我的代码如下所示:
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
然而,每个图像的特征贴图保持不变。我是否需要以某种方式重置网络中间或如何完成此操作?