caffe:Data 层

在看caffe教程中Fine-tuning for style recognition时比较image_net和style微调网络结构时,发现两个不同的Data layer的类型Data 和 ImageData,如下:

**name: "CaffeNet"**
layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    mirror: true
    crop_size: 227
    mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"
  }
# mean pixel / channel-wise mean instead of mean image
#  transform_param {
#    crop_size: 227
#    mean_value: 104
#    mean_value: 117
#    mean_value: 123
#    mirror: true
#  }
  data_param {
    source: "examples/imagenet/ilsvrc12_train_lmdb"
    batch_size: 256
    backend: LMDB
  }
}
**name: "FlickrStyleCaffeNet"**
layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    mirror: true
    crop_size: 227
    mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"
  }
  image_data_param {
    source: "data/flickr_style/train.txt"
    batch_size: 50
    new_height: 256
    new_width: 256
  }
}

查看文档资料发现,原来Data layer不仅能接受lmdb和leveldb格式的数据,也能通过设置类型为ImageData,提供文件列表和*.jpg,绕过转换过程,直接提供给caffe。
参考:http://caffe.berkeleyvision.org/tutorial/layers.html
中 Data Layers

Data enters Caffe through data layers: they lie at the bottom of nets. Data can come from efficient databases (LevelDB or LMDB), directly from memory, or, when efficiency is not critical, from files on disk in HDF5 or common image formats.

Common input preprocessing (mean subtraction, scaling, random cropping, and mirroring) is available by specifying TransformationParameters.

Database

Layer type: Data
Parameters
Required
source: the name of the directory containing the database
batch_size: the number of inputs to process at one time
Optional
rand_skip: skip up to this number of inputs at the beginning; useful for asynchronous sgd
backend [default LEVELDB]: choose whether to use a LEVELDB or LMDB
In-Memory

Layer type: MemoryData
Parameters
Required
batch_size, channels, height, width: specify the size of input chunks to read from memory
The memory data layer reads data directly from memory, without copying it. In order to use it, one must call MemoryDataLayer::Reset (from C++) or Net.set_input_arrays (from Python) in order to specify a source of contiguous data (as 4D row major array), which is read one batch-sized chunk at a time.

HDF5 Input

Layer type: HDF5Data
Parameters
Required
source: the name of the file to read from
batch_size
HDF5 Output

Layer type: HDF5Output
Parameters
Required
file_name: name of file to write to
The HDF5 output layer performs the opposite function of the other layers in this section: it writes its input blobs to disk.

Images

Layer type: ImageData
Parameters
Required
source: name of a text file, with each line giving an image filename and label
batch_size: number of images to batch together
Optional
rand_skip
shuffle [default false]
new_height, new_width: if provided, resize all images to this size
Windows

WindowData

Dummy

DummyData is for development and debugging. See DummyDataParameter.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值