caffe Python API 之 数据输入层(Data,ImageData,HDF5Data)
import sys
sys.path.append('/projects/caffe-ssd/python')
import caffe
4 net = caffe.NetSpec()
一、ImageData Layer
net.data ,net.label = caffe.layers.ImageData(
name="InputData"
source="train.txt",
batch_size=32,
new_width=48,
new_height=48,
ntop=2,
is_color=True,
shuffle=True,
root_folder='/',
transform_param=dict(crop_size=40,mirror=True))
print str(net.to_proto()) 输出:
layer {
name: "InputData"
type: "ImageData"
top: "data"
top: "label"
transform_param {
mirror: true
crop_size: 40
}
image_data_param {
source: "train.txt"
batch_size: 32
shuffle: true
new_height: 48
new_width: 48
is_color: true
root_folder: "/"
}
}
二、Data Layer (lmdb/leveldb)
net.data, net.label = caffe.layers.Data(
name="InputData",
source="train_lmdb",
backend = caffe.params.Data.LMDB,
batch_size=32,
ntop=2,
include=dict(phase=caffe.TRAIN)
transform_param=dict(
crop_size=227,
mean_value=[104, 117, 123],
mirror=True
)
) 输出:
layer {
name: "InputData"
type: "Data"
top: "data"
top: "label"
transform_param {
mirror: true
crop_size: 227
mean_value: 104
mean_value: 117
mean_value: 123
}
data_param {
source: "train_lmdb"
batch_size: 32
backend: LMDB
}
}
三、HDF5Data Layer
net.data, net.label = caffe.layers.HDF5Data(
name="InputData",
source='./training_data_paths.txt',
batch_size=64,
include=dict(phase=caffe.TRAIN),
ntop=2
) 输出:
layer {
name: "InputData"
type: "HDF5Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
hdf5_data_param {
source: "./training_data_paths.txt"
batch_size: 64
}
} 另有:
image = L.HDF5Data(
hdf5_data_param={ 'source': './training_data_paths.txt', 'batch_size': 64 },
include={'phase': caffe.TRAIN }
)
caffe Python API 之 数据输入层(Data,ImageData,HDF5Data)的更多相关文章
- caffe添加自己的数据输入层
整体思路: 阅读caffe数据输入层各个类之间的继承关系,确定当前类需要继承的父类以及所需参数的设置. 编写zzq_data.cpp 在layer_factory.cpp中完成注册: 在caffe.p ...
- 【caffe I/O】数据读取层 代码中文注释
caffe.proto中DataParameter部分 message DataParameter { //输入数据使用的DB类型 enum DB { LEVELDB = ;//使用LEVELDB L ...
- caffe Python API 之卷积层(Convolution)
1.Convolution层: 就是卷积层,是卷积神经网络(CNN)的核心层. 层类型:Convolution lr_mult: 学习率的系数,最终的学习率是这个数乘以solver.prototxt配 ...
- caffe Python API 之上卷积层(Deconvolution)
对于convolution: output = (input + 2 * p - k) / s + 1; 对于deconvolution: output = (input - 1) * s + k ...
- caffe Python API 之可视化
一.显示各层 # params显示:layer名,w,b for layer_name, param in net.params.items(): print layer_name + '\t' + ...
- caffe Python API 之图片预处理
# 设定图片的shape格式为网络data层格式 transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape}) ...
- caffe Python API 之激活函数ReLU
import sys import os sys.path.append("/projects/caffe-ssd/python") import caffe net = caff ...
- caffe Python API 之Inference
#以SSD的检测测试为例 def detetion(image_dir,weight,deploy,resolution=300): caffe.set_mode_gpu() net = caffe. ...
- caffe Python API 之中值转换
# 编写一个函数,将二进制的均值转换为python的均值 def convert_mean(binMean,npyMean): blob = caffe.proto.caffe_pb2.BlobPro ...
随机推荐
- main方法为什么是静态的
main函数其实也是所在类的一个方法,就比如一个类是test,那么该类的main其实就是test.main(String[] args),众所周知如果一个方法不是静态的,则要先实例化该类,比如要这样 ...
- vscode Variables Reference
vscode Variables Reference 您可以在以下链接中找到该列表:https://code.visualstudio.com/docs/editor/variables-refere ...
- [LOJ #2473] [九省联考2018] 秘密袭击coat
题目链接 洛谷. LOJ,LOJ机子是真的快 Solution 我直接上暴力了...\(O(n^2k)\)洛谷要\(O2\)才能过...loj平均单点一秒... 直接枚举每个点为第\(k\)大的点,然 ...
- bzoj3709: [PA2014]Bohater 贪心
~~~题面~~~ 题解: 首先有一个比较明显的策略,肯定先要把能带给自己受益的先选完,然后再以最佳状态去打那些会给自己带来损失的怪. 对于前一部分(可以带来受益的怪),显然我们需要先从代价小的打起,因 ...
- Android ListView的优化
最近的项目中有通讯录这个模块,里面的通讯录涉及的联系人数量很大,导致在加载页面的时候有点卡,所以就必须得进行优化,优化的最终实现理论是什么?就是让ListView一次性加载的数据较少,后续根据用户操作 ...
- POJ3254:Corn Fields——题解
http://poj.org/problem?id=3254 题面来自洛谷:https://www.luogu.org/problemnew/show/1879 农场主John新买了一块长方形的新牧场 ...
- POJ3907:Build Your Home——题解
http://poj.org/problem?id=3907 题目大意:求多边形面积,结果四舍五入. ———————————————————— 多边形面积公式板子题. #include<cstd ...
- POJ3690:Constellations——题解
http://poj.org/problem?id=3690 题目大意:给一个图和几个子图,判断有多少种子图在原图出现过. —————————————————————— 二维哈希即可,操作看代码,我觉 ...
- BZOJ2428:[HAOI2006]均分数据——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=2428 https://www.luogu.org/problemnew/show/P2503 已知 ...
- c++ linux 判断string是中文的 or 英文的 字符串。
#include <iostream> #include <string.h> #include <stdio.h> #include <stdlib.h&g ...