layer { type: 'Python' name: 'AlexNet' top: 'AlexNet' bottom: "Images" python_param { # the module name -- usually the filename -- that needs to be in $PYTHONPATH module: 'net_wrapper' # the layer name -- the class name in the module layer: 'AlexNetWrap' }}
class AlexNetWrap(caffe.Layer):
def setUp(self):
net_file = './alexnet.prototxt'
weights = '/home/valeodar/caffe_0/models/bvlc_reference_caffenet/params.caffemodel'
self.net = caffe.Net(net_file, weights, caffe.TRAIN)
print 'wtf'
def reshape(self, bottom, top):
# check input dimensions match
if bottom[0].count != bottom[1].count:
raise Exception("Inputs must have the same dimension.")
# difference is shape of inputs
self.diff = np.zeros_like(bottom[0].data, dtype=np.float32)
# loss output is scalar
top[0].reshape(1)
def forward(self, bottom, top):
self.forward(bottom,top)
def backward(self, top, bottom):
self.backward(bottom,top)