在使用caffe的python接口时,
如下,如果标黄的部分不加上的话,两次调用该函数,后面的会将前面的返回值覆盖掉,也就是fea1与fea2相等,但是fea1_ori会保留原来的fea1
解决方法为使用fea1_ori或者加上标黄对的copy即可;
def apply_model(image, net, filename): net.blobs['data'].data[...] = image output = net.forward() feat_vector = (net.blobs['norm2'].data[0]).copy() feat_vector = np.squeeze(feat_vector) return (feat_vector) #调用 fea1 = apply_model(img1, net, image_name) fea1_ori = fea1.copy() print "fea1 is ", fea1 fea2 = apply_model(img2, net, image_name) print "fea1 is ", fea1 print "fea2 is ", fea2 print "fea1_ori is ", fea1_ori
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:python滴啊用caffe时的小坑 - Python技术站