caffe - Why the features are overwritten when extracted using pycaffe? -


i observed features overwritten when extract them using pycaffe. code follows:

timg_1 = misc.imread('1.jpg') timg_1 = timg_1[:,:,::-1] # color channel swap timg_2 = misc.imread('2.jpg') timg_2 = timg_2[:,:,::-1] # color channel swap  timg_1 = (np.float32(timg_1)- 127.5)/128 # mean substruction timg_2 = (np.float32(timg_2)- 127.5)/128 # mean substruction  ti_1 = np.moveaxis(timg_1, 0, 1) # transpose ti_2 = np.moveaxis(timg_2, 0, 1) # transpose  # extract features ti_1 = np.reshape(timg_1, (1, timg_1.shape[2], timg_1.shape[0], timg_1.shape[1])) ti_2 = np.reshape(timg_2, (1, timg_2.shape[2], timg_2.shape[0],     timg_2.shape[1]))                  net.blobs['data'].data[...] = ti_1 net.forward()  fts_1 = net.blobs['fc5'].data print(fts_1[0, 0])                   net.blobs['data'].data[...] = ti_2 net.forward()  fts_2 = net.blobs['fc5'].data                    print(fts_2[0, 0])                  print(fts_1[0, 0]) 

executing provides following output:

0.508398 -0.176945 -0.176945 

that means values of fts_1 overwritten fts_2. how can avoid problem?

fts_1 pointing net.blobs['fc5'].data. need make deepcopy of object. first assignment should fts_1 = copy.deepcopy(net.blobs['fc5'].data)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -