简体   繁体   中英

caffe layer zero output-python

I get the output of the VGG-changed network(here is vectors of 3 float numbers)every thing is OK, but when I just want to get the output of other layers(eg last convolution layer conv5_4) instead of the last layer, the output vectors are all zero. This is the python code to get the output:

import sys
import cv2
import numpy as np
sys.path.insert(0, '/home/deep/rahim/caffe-master/python')
import caffe
input_image_file = sys.argv[1]
output_file = sys.argv[2]
model_file = '/home/deep/rahim/PGM/Final/feature/deep/snapshot_iter_355000.caffemodel'
deploy_prototxt = '/home/deep/rahim/PGM/Final/feature/deep/deploy.prototxt'
net = caffe.Net(deploy_prototxt, model_file, caffe.TEST)
layer = 'conv5_4'
transformer = caffe.io.Transformer({'data':       net.blobs['data'].data.shape})
transformer.set_transpose('data', (2,0,1))
transformer.set_raw_scale('data', 255.0)
net.blobs['data'].reshape(1,3,40,40)
img = caffe.io.load_image(input_image_file)
net.blobs['data'].data[...] = transformer.preprocess('data', img)
output = net.forward()
print '%s' %(net.blobs[layer].data[0])

please help me

I changed the model from VGG-changed to LENET. the problem solved. It seemed the changed to vgg causes the above problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM