caffe增加自己的layer实战(下-续1)--caffe学习(13)
来源:互联网 发布:中国网络教育干部学院 编辑:程序博客网 时间:2024/06/05 03:32
接上篇:caffe增加自己的layer实战(下)–caffe学习(12)
构造完函数后我们就要进入proto目录。编辑caffe.proto文件,构造我们的video_data_layer的输入参数。
找到:message LayerParameter {
里面有很多类似: optional PythonParameter python_param = 130;
我们要为自己的video_data_layer添加一个optional
如:
optional VideoDataParameter video_data_param = 140;
要保证后面的140不要与这里面的其他数字重复,保证是唯一的。
然后对这个输入参数写对应的message:
像这样:
message VideoDataParameter{ // Specify the data source. optional string source = 1; // Specify the batch size. optional uint32 batch_size = 4; // The rand_skip variable is for the data layer to skip a few data points // to avoid all asynchronous sgd clients to start at the same point. The skip // point would be set as rand_skip * rand(0,1). Note that rand_skip should not // be larger than the number of keys in the leveldb. optional uint32 rand_skip = 7 [default = 0]; // Whether or not ImageLayer should shuffle the list of files at every epoch. optional bool shuffle = 8 [default = false]; // It will also resize images if new_height or new_width are not zero. optional uint32 new_height = 9 [default = 0]; optional uint32 new_width = 10 [default = 0]; optional uint32 new_length = 11 [default = 1]; optional uint32 num_segments = 12 [default = 1]; // DEPRECATED. See TransformationParameter. For data pre-processing, we can do // simple scaling and subtracting the data mean, if provided. Note that the // mean subtraction is always carried out before scaling. optional float scale = 2 [default = 1]; optional string mean_file = 3; // DEPRECATED. See TransformationParameter. Specify if we would like to randomly // crop an image. optional uint32 crop_size = 5 [default = 0]; // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror // data. optional bool mirror = 6 [default = false]; enum Modality { RGB = 0; FLOW = 1; } optional Modality modality = 13 [default = FLOW]; // the name pattern for frame images, // for RGB modality it is default to "img_%04d.jpg", for FLOW "flow_x_%04d" and "flow_y_%04d" optional string name_pattern = 14; // The type of input optional bool encoded = 15 [default = false];}
现在开始在就是对输入prototxt参数进行类型定义和默认值。
现在全部所需都完成了。
进入caffe目录 make clean
make all -j8
make install
更新,
最后也是最容易忽视的一点,在 Layer 工厂注册新 Layer 加工函数,不然在你运行过程中可能会报如下错误:
F1002 01:51:22.656038 1954701312 layer_factory.hpp:81] Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer type: AllPass (known types: AbsVal, Accuracy, ArgMax, BNLL, BatchNorm, BatchReindex, Bias, Concat, ContrastiveLoss, Convolution, Crop, Data, Deconvolution, Dropout, DummyData, ELU, Eltwise, Embed, EuclideanLoss, Exp, Filter, Flatten, HDF5Data, HDF5Output, HingeLoss, Im2col, ImageData, InfogainLoss, InnerProduct, Input, LRN, Log, MVN, MemoryData, MultinomialLogisticLoss, PReLU, Pooling, Power, ReLU, Reduction, Reshape, SPP, Scale, Sigmoid, SigmoidCrossEntropyLoss, Silence, Slice, Softmax, SoftmaxWithLoss, Split, TanH, Threshold, Tile, WindowData) *** Check failure stack trace: *** @ 0x10243154e google::LogMessage::Fail() @ 0x102430c53 google::LogMessage::SendToLog() @ 0x1024311a9 google::LogMessage::Flush() @ 0x1024344d7 google::LogMessageFatal::~LogMessageFatal() @ 0x10243183b google::LogMessageFatal::~LogMessageFatal() @ 0x102215356 caffe::LayerRegistry<>::CreateLayer() @ 0x102233ccf caffe::Net<>::Init() @ 0x102235996 caffe::Net<>::Net() @ 0x102118d8b time() @ 0x102119c9a main @ 0x7fff851285ad start @ 0x4 (unknown) Abort trap: 6
主要错误提示是:Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer type: VideoDataLayer
解决办法:
全部成功以后
新建一个train.prototxt文件,用最简单的LeNet网络做测试。
name: "LeNet"layer { name: "data" type: "VideoData" top: "data" top: "label" video_data_param { source: "data/hmdb51_rgb_train_split_1.txt" batch_size: 32 new_length: 1 num_segments: 3 modality: RGB shuffle: true name_pattern: "img_%05d.jpg" } transform_param{ crop_size: 224 mirror: true fix_crop: true more_fix_crop: true multi_scale: true max_distort: 1 scale_ratios:[1,.875,.75, .66] is_flow: false mean_value: [104, 117, 123, 104, 117, 123, 104, 117, 123] } include: { phase: TRAIN }}layer { name: "reshape_data" type: "Reshape" bottom: "data" top: "reshape_data" reshape_param { shape { dim: -1 dim: 3 dim: 224 dim: 224 } } }layer { name: "conv1" type: "Convolution" bottom: "data" top: "conv1" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 20 kernel_size: 5 stride: 1 weight_filler { type: "xavier" } bias_filler { type: "constant" } }}layer { name: "pool1" type: "Pooling" bottom: "conv1" top: "pool1" pooling_param { pool: MAX kernel_size: 2 stride: 2 }}layer { name: "conv2" type: "Convolution" bottom: "pool1" top: "conv2" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 50 kernel_size: 5 stride: 1 weight_filler { type: "xavier" } bias_filler { type: "constant" } }}layer { name: "pool2" type: "Pooling" bottom: "conv2" top: "pool2" pooling_param { pool: MAX kernel_size: 2 stride: 2 }}layer { name: "ip1" type: "InnerProduct" bottom: "pool2" top: "ip1" param { lr_mult: 1 } param { lr_mult: 2 } inner_product_param { num_output: 500 weight_filler { type: "xavier" } bias_filler { type: "constant" } }}layer { name: "relu1" type: "ReLU" bottom: "ip1" top: "ip1"}layer { name: "ip2" type: "InnerProduct" bottom: "ip1" top: "ip2" param { lr_mult: 1 } param { lr_mult: 2 } inner_product_param { num_output: 10 weight_filler { type: "xavier" } bias_filler { type: "constant" } }}layer { name: "prob" type: "Softmax" bottom: "ip2" top: "prob"}
上面的source: "data/hmdb51_rgb_train_split_1.txt"
文件内容如下:
data/Sara_beim_Rauchen_-_Volume_3_smoke_h_cm_np1_fr_med_0 77 0
这里我们只拿一个视频进行测试
数据在链接:http://pan.baidu.com/s/1eSMHquu 密码:06e4
0 0
- caffe增加自己的layer实战(下-续1)--caffe学习(13)
- caffe增加自己的layer实战(下)--caffe学习(12)
- caffe增加自己的layer实战(上)--caffe学习(10)
- caffe增加自己的layer实战(中)--caffe学习(11)
- caffe中增加自己的layer
- caffe增加自己的layer教程集合
- caffe学习(2)------用caffe训练自己的图片
- caffe源码学习(四) layer
- caffe源码学习(五) data layer
- 学习Caffe(四)Loss Layer解析
- Caffe:Layer的相关学习
- 深度学习Caffe实战笔记(6)Windows caffe平台用Siamese网络跑自己的数据
- 深度学习Caffe实战笔记(3)用AlexNet跑自己的数据
- 深度学习Caffe实战笔记(19)Windows平台 Faster-RCNN 制作自己的数据集
- 深度学习Caffe实战笔记(20)Windows平台 Faster-RCNN 训练自己的数据集
- 深度学习Caffe实战笔记(19)Windows平台 Faster-RCNN 制作自己的数据集
- Caffe学习笔记1:linux下建立自己的数据库训练和测试caffe中已有网络
- 深度学习caffe实战笔记(4)Windows caffe平台下跑cifar10
- Linux系统中各种系统日志文件主要存放在系统中哪个目录
- java的switch语句问题
- redis高可用集群介绍
- 一键打包出多个不同包名,不同应用名称和图标的APK
- Java六大设计原则-单一原则
- caffe增加自己的layer实战(下-续1)--caffe学习(13)
- 产品经理笔试面试题(网搜资源)
- iOS子线程操作总结
- githug关卡小游戏,练习git
- 防盗链
- TexturePacker 批处理
- 55.自定义View练习(三)圆形进度条控件
- Laravel本就好玩
- Echars示例总结