【caffe】Layer解读之:Date

  • Layer type: Date
  • 头文件位置:./include/caffe/layers/data_layer.hpp
  • CPU 执行源文件位置:./src/caffe/layers/data_layer.cpp
  • Date层的功能:读取LevelDB,LMDB,并进行一系列前处理。
layer {
  name: "cifar"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }

  transform_param {
    scale:0.0078125
    mirror:true
    crop_size:32
    mean_value: 128
    mean_value: 128
    mean_value: 128
  }
  data_param {
    source: "examples/cifar10/cifar10_train_lmdb"
    batch_size: 32
    backend: LMDB
  }
}

参数定义

message DataParameter {
  enum DB {
    LEVELDB = 0;
    LMDB = 1;
  }
  // 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 database.
  // DEPRECATED. Each solver accesses a different subset of the database.
  //在开头跳过这个数量的输入; 对异步sgd很有用
  optional uint32 rand_skip = 7 [default = 0];
  optional DB backend = 8 [default = LEVELDB];
  // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
  // simple scaling and subtracting the data mean, if provided. Note that the
   // 数据比例缩放,注意该操作处于减均值操作之后
  optional float scale = 2 [default = 1];
  // 指定均值文件路径,注意不能同时指定mean_file 和 mean_value
  optional string mean_file = 3;
  // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
  // 指定从原图随机crop的尺寸
  optional uint32 crop_size = 5 [default = 0];
  // 是否要对输入图像采用随机水平镜像See TransformationParameter. 
  optional bool mirror = 6 [default = false];
  // 强制将图片转为三通道彩色图片
  optional bool force_encoded_color = 9 [default = false];
  // 预先存取多少个batch到host memory
  // (每次forward完成之后再全部重新取一个batch比较浪费时间), 
  optional uint32 prefetch = 10 [default = 4];
}
transform_param
// 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];
}
data_param
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 = ""];
}

caffe源码之ImageDataLayer解析
caffe】caffe中使用crop_size剪裁训练图片
caffe源码解读(5)-image_data_layer.cpp

猜你喜欢

转载自blog.csdn.net/qiu931110/article/details/81746672