I am trying to do a conv-net forward pass after manually setting the data blobs in conv5 in pycaffe.
In the demo below, I loaded VGG16, and tried to update the pycaffe Net object's internal blobs with random values before trying to run a forward pass. When conv5 flag is set to True, repeated execution does not yield different output when I print fc8_forward. In contrast, the else block runs as expected.
Any advice on this matter is greatly appreciated.
Also, I would also like to hear advice regarding whether I should be copying my numpy arrays before using them in the C++ bindings.
Thank you for your help in advance!
```
import caffe
import numpy as np
caffe_root = '/somewhere/caffe'
caffe.set_mode_gpu()
net = caffe.Net(caffe_root + 'models/bvlc_reference_caffenet/deploy_hallucination.prototxt',
caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel',
caffe.TEST)
conv5 = True
if conv5: # doesn't work -- i.e. fc8_forward does not change on repeated execution of this code block
x = np.random.rand(1,256,13,13)*255
net.blobs['conv5'].data[...] = x.copy()
curr_forward = net.forward(start = 'pool5',end='fc8')
# also tried start = 'conv5'. pool5 is right after conv5 -- same behavior
else: # this works as expected
y= np.random.rand(1,3,227,227)*255
net.blobs['data'].data[...] = y.copy()
curr_forward = net.forward(start = 'conv1',end='fc8')
fc8_forward = np.array(curr_forward['fc8'].flat)
print fc8_forward
```
The layers in VGG 16 are:
['data', 'conv1', 'pool1', 'norm1', 'conv2', 'pool2', 'norm2', 'conv3', 'conv4', 'conv5', 'pool5', 'fc6', 'fc7', 'fc8', 'prob']