This tutorial will guide through the steps to create a simple custom layer for Caffe using python.
###Why would I want to do that? Usually you would create a custom layer to implement a funcionality that isn't available in Caffe, tuning it for your requirements.
###What will I need? Python and Caffe instaled and a sample layer template (provided bellow) so you can customize it.
##Layer Template
import caffe
class My_Custom_Layer(caffe.Layer):
def setup(self, bottom, top):
pass
def forward(self, bottom, top):
pass
def reshape(self, bottom, top):
pass
def backward(self, bottom, top):
passSo important things to remember:
- Your custom layer has to inherit from caffe.Layer (so don't forget to import caffe);
- You must define the four following methods: setup, forward, reshape, backward;
###Setup method
###Reshape method
###Forward method
###Backward method