caffe层解读系列——Data以及ImageData层用法

来源:互联网 发布:leancloud导入数据 编辑:程序博客网 时间:2024/04/28 08:12

直接举一个data层的使用例子:

layer {  name: "cifar"  type: "Data"  top: "data"  top: "label"  include {    phase: TRAIN  }  transform_param {    mean_value: 128    mean_value: 128    mean_value: 128    ......  }  data_param {    source: "examples/cifar10/cifar10_train_lmdb"    batch_size: 111    backend: LMDB    ......  }}

Data 参数

// Data 参数message DataParameter {  // 只支持下面两种数据格式  enum DB {    LEVELDB = 0;    LMDB = 1;  }  // 指定数据路径  optional string source = 1;  // 指定batchsize  optional uint32 batch_size = 4;  // 指定数据格式  optional DB backend = 8 [default = LEVELDB];  // 强制将图片转为三通道彩色图片  optional bool force_encoded_color = 9 [default = false];  // 预先存取多少个batch到host memory  // (每次forward完成之后再全部重新取一个batch比较浪费时间),   // increase if data access bandwidth varies).  optional uint32 prefetch = 10 [default = 4];}

transform 参数

// transform 参数message TransformationParameter {  // 数据比例缩放,注意该操作处于减均值操作之后  optional float scale = 1 [default = 1];  // 是否要对输入图像采用随机水平镜像  optional bool mirror = 2 [default = false];  // 指定从原图随机crop的尺寸  optional uint32 crop_size = 3 [default = 0];  // 指定均值文件路径,注意不能同时指定mean_file 和 mean_value  optional string mean_file = 4;  // 指定均值,如果只指定一个均值,则所有通道均减去该均值;如果指定了多个,则每个通道减去对应均值  repeated float mean_value = 5;  // 是否强制转为三通道图像  optional bool force_color = 6 [default = false];  // 强制转为单通道图像  optional bool force_gray = 7 [default = false];}

ImageData参数

message ImageDataParameter {  // Specify the data source.  optional string source = 1;  // Specify the batch size.  optional uint32 batch_size = 4 [default = 1];  // 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 database.  optional uint32 rand_skip = 7 [default = 0];  // 每一个 epoch是否打乱数据.  optional bool shuffle = 8 [default = false];  // 如果new_height or new_width 不等于0,则会resize图像.  optional uint32 new_height = 9 [default = 0];  optional uint32 new_width = 10 [default = 0];  // 指定图片为彩色还是灰度图  optional bool is_color = 11 [default = true];  // 数据比例缩放,注意该操作处于减均值操作之后  optional float scale = 2 [default = 1];  //均值文件路径  optional string mean_file = 3;  //图片数据根目录  optional string root_folder = 12 [default = ""];}
1 0
原创粉丝点击