我想找一个caffe数据层示例来学习。我知道Fast有一个python数据层,但它相当复杂,因为我不熟悉对象检测。
因此,我的问题是,是否有一个python数据层示例,可以学习如何定义自己的数据准备过程?
例如,如何定义python数据层可以进行更多的数据增强(例如平移、旋转等)。比首席执行官"ImageDataLayer"。
非常感谢
发布于 2016-01-25 15:47:22
您可以使用"Python"层:在python中实现的一层将数据输入到您的网络中。(请参见添加type: "Python"层here的示例)。
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有关param_str的更多信息,请参见this thread。
您可以使用预取here找到数据加载层的草图。
发布于 2016-01-26 15:38:32
@Shai的回答很棒。同时,我在caffe的一个PR中找到了另一个关于python数据层的详细示例。https://github.com/BVLC/caffe/pull/3471/files我希望这个详细的例子能对其他人有所帮助。
https://stackoverflow.com/questions/34996075
复制相似问题