[Caffe]: HDF5Data Layer
[Caffe]: HDF5Data Layer
Tensorflow、Pytorch和Caffe2的相继问世后,Caffe的热度和优势已逐渐消失。
最近,为了跑对比的实验,用到了HDF5Data层。
遇到一些问题,写篇博客记录以下。
HDF5Data Layer
// Message that stores parameters used by HDF5DataLayer
message HDF5DataParameter {// Specify the data source.optional string source = 1;// Specify the batch size.optional uint32 batch_size = 2;// Specify whether to shuffle the data.// If shuffle == true, the ordering of the HDF5 files is shuffled,// and the ordering of data within any given HDF5 file is shuffled,// but data between different files are not interleaved; all of a file's// data are output (in a random order) before moving onto another file.optional bool shuffle = 3 [default = false];
}
HDF5Data层是Caffe提供的能够灵活控制输入数据的接口,上图是它的参数定义。如上图,HDF5Data层只有3种参数,一个指定路径的list、一个指定每个批次的训练数量和是否打乱训练数据顺序。
HDF5文件生成
使用该层需要将数据存成hdf5格式,这通过python能够很容易的实现。
推荐用h5py库,仅需三行就能将numpy存进一个hdf5文件里。
import h5py
import numpy as npdata = np.random.randn(128,1)
with h5py.File('test.h5', 'w') as fh:fh.create_dataset('data', data=data)
使用HDF5Data层
layer{name:"data"type:"HDF5Data"top:"data"top:"label"include{phase:TRAIN}hdf5_data_param{source:"train.txt" #train.txt保存h5文件的路径,可包含多个路径,每行一个batch_size: 256shuffle: true #是否打乱同一个文件内的数据顺序}
}
如图所示,HDF5Data层不支持减均值、随机剪切等数据操作,所以要在创建HDF5文件时完成。
综上,HDF5Data层还是蛮好用的。
2018.03.16 记
最新文章
- 软件定义网络是否会终结命令行界面的命运
- Google正在测试最新升级的句法搜索功能
- 浪潮存储与虚拟服务器连接失败,浪潮
- 为什么要建议用自增列做主键
- hadoop命令无法创建目录
- 集群和均衡负载[摘]
- 困扰的Byte、bit 、和16进制之间的关系
- 1
- EmguCV学习(一)
- mysql 10931142
- Centos7 安装Nexus
- 做自媒体18个月,倒欠38万,一个自媒体创作者的自述
- 强制应用横竖屏的简单设置
- PTA(十一)计算指数
- python可视化的优势
- c++ grpc compress(deflate算法) demo编译
- 程序员咋学习
- tensorflow function笔记: tf.tile
- call方法PHP,php
- HTML中的JavaScript——<script>