kli*_*lpr 10 neural-network deep-learning caffe pycaffe
我想找一个要学习的caffe python数据层示例.我知道Fast-RCNN有一个python数据层,但由于我不熟悉对象检测,所以它相当复杂.
所以我的问题是,是否有一个python数据层示例,我可以学习如何定义自己的数据准备过程?
例如,如何定义python数据层比caffe做更多的数据扩充(例如转换,旋转等)"ImageDataLayer"
.
非常感谢你
Sha*_*hai 12
您可以使用"Python"
图层:在python中实现的图层,以将数据提供给您的网络.(请参阅此处添加type: "Python"
图层的示例).
import sys, os
sys.path.insert(0, os.environ['CAFFE_ROOT']+'/python')
import caffe
class myInputLayer(caffe.Layer):
def setup(self,bottom,top):
# read parameters from `self.param_str`
...
def reshape(self,bottom,top):
# no "bottom"s for input layer
if len(bottom)>0:
raise Exception('cannot have bottoms for input layer')
# make sure you have the right number of "top"s
if len(top)!= ...
raise ...
top[0].reshape( ... ) # reshape the outputs to the proper sizes
def forward(self,bottom,top):
# do your magic here... feed **one** batch to `top`
top[0].data[...] = one_batch_of_data
def backward(self, top, propagate_down, bottom):
# no back-prop for input layers
pass
Run Code Online (Sandbox Code Playgroud)
有关param_str
查看此主题的更多信息.
您可以在此处找到带有预取的数据加载层的草图.
@ Shai的答案很棒.同时,我在一个caffe-master的PR中找到了另一个关于python数据层的详细例子.https://github.com/BVLC/caffe/pull/3471/files 我希望这个详细的例子对其他人有帮助.