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)的更多相关文章

  1. caffe添加自己的数据输入层

    整体思路: 阅读caffe数据输入层各个类之间的继承关系,确定当前类需要继承的父类以及所需参数的设置. 编写zzq_data.cpp 在layer_factory.cpp中完成注册: 在caffe.p ...

  2. 【caffe I/O】数据读取层 代码中文注释

    caffe.proto中DataParameter部分 message DataParameter { //输入数据使用的DB类型 enum DB { LEVELDB = ;//使用LEVELDB L ...

  3. caffe Python API 之卷积层(Convolution)

    1.Convolution层: 就是卷积层,是卷积神经网络(CNN)的核心层. 层类型:Convolution lr_mult: 学习率的系数,最终的学习率是这个数乘以solver.prototxt配 ...

  4. caffe Python API 之上卷积层(Deconvolution)

    对于convolution: output = (input + 2 * p  - k)  / s + 1; 对于deconvolution: output = (input - 1) * s + k ...

  5. caffe Python API 之可视化

    一.显示各层 # params显示:layer名,w,b for layer_name, param in net.params.items(): print layer_name + '\t' + ...

  6. caffe Python API 之图片预处理

    # 设定图片的shape格式为网络data层格式 transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape}) ...

  7. caffe Python API 之激活函数ReLU

    import sys import os sys.path.append("/projects/caffe-ssd/python") import caffe net = caff ...

  8. caffe Python API 之Inference

    #以SSD的检测测试为例 def detetion(image_dir,weight,deploy,resolution=300): caffe.set_mode_gpu() net = caffe. ...

  9. caffe Python API 之中值转换

    # 编写一个函数,将二进制的均值转换为python的均值 def convert_mean(binMean,npyMean): blob = caffe.proto.caffe_pb2.BlobPro ...

随机推荐

  1. BZOJ4300 绝世好题(动态规划)

    设f[i][j]为前i个数中所选择的最后一个数在第j位上为1时的最长序列长度,转移显然. #include<iostream> #include<cstdio> #includ ...

  2. BZOJ4245 ONTAK2015 OR-XOR(贪心)

    贪心的按位考虑.如果所有数在某一位上有奇数个为1,显然无论如何划分这一位最终都会为1:否则将每一部分都划分为偶数个1就能保证最终该位为0,可以标记上哪些位置可以作为划分点(当然也要满足之前可为0的位上 ...

  3. BZOJ3631:[JLOI2014]松鼠的新家——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=3631 https://www.luogu.org/problemnew/show/P3258 松鼠的 ...

  4. NOIP2016Day1T3换教室(floyd+期望dp)

    啊...这个时间写博客,明天还要上学,整个人都不好了... 这是我写的第一道期望题hiahiahia... 题目大意就不说了QWQ 80分儿做法:先floyd,爆搜枚举哪些点取,求出答案,效率O(C( ...

  5. 使用openssl进行文件加密

    #include <iostream> #include <string> #include <stdlib.h> using namespace std; int ...

  6. angularJS入门小Demo【简单测试js代码的方法】

    1.首先建立一个文件夹 demo, 2.在其中建立一个文本文档,改名为 demo-1.html, 3.把html中要引入的 js 文件拷贝到 demo目录下, 4.然后用 Notepadd++ 编辑刚 ...

  7. SPOJ - HIGH :Highways (生成树计数)

    Highways 题目链接:https://vjudge.net/problem/SPOJ-HIGH Description: In some countries building highways ...

  8. Machine Learning CodeForces - 940F (带修改的莫队)

    You come home and fell some unpleasant smell. Where is it coming from? You are given an array a. You ...

  9. Java并发编程学习笔记

    Java编程思想,并发编程学习笔记. 一.基本的线程机制 1.定义任务:Runnable接口 线程可以驱动任务,因此需要一种描述任务的方式,这可以由Runnable接口来提供.要想定义任务,只需实现R ...

  10. Linux查看内核和系统版本

    1. 查看内核版本命令: 1) [root@q1test01 ~]# cat /proc/version Linux version 2.6.9-22.ELsmp (bhcompile@crowe.d ...