import sys
import os
sys.path.append("/projects/caffe-ssd/python")
import caffe net = caffe.NetSpec()
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
)
)
net.myconv = caffe.layers.Convolution(
net.data,
kernel_size=3,
stride=1,
pad=1,
num_output=20,
group=2,
weight_filler=dict(type='xavier'),
bias_filler=dict(type='constant',value=0)) net.myrelu = caffe.layers.ReLU(net.myconv, in_place=True) print(str(net.to_proto())) 输出:
layer {
name: "InputData"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
mirror: true
crop_size: 227
mean_value: 104.0
mean_value: 117.0
mean_value: 123.0
}
data_param {
source: "train_lmdb"
batch_size: 32
backend: LMDB
}
}
layer {
name: "myconv"
type: "Convolution"
bottom: "data"
top: "myconv"
convolution_param {
num_output: 20
pad: 1
kernel_size: 3
group: 2
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0.0
}
}
}
layer {
name: "myrelu"
type: "ReLU"
bottom: "myconv"
top: "myconv"
}

caffe Python API 之激活函数ReLU的更多相关文章

  1. caffe Python API 之中值转换

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

  2. caffe Python API 之 数据输入层(Data,ImageData,HDF5Data)

    import sys sys.path.append('/projects/caffe-ssd/python') import caffe4 net = caffe.NetSpec() 一.Image ...

  3. caffe Python API 之BatchNormal

    net.bn = caffe.layers.BatchNorm( net.conv1, batch_norm_param=dict( moving_average_fraction=0.90, #滑动 ...

  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 之Inference

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

  7. caffe Python API 之图片预处理

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

  8. caffe Python API 之Model训练

    # 训练设置 # 使用GPU caffe.set_device(gpu_id) # 若不设置,默认为0 caffe.set_mode_gpu() # 使用CPU caffe.set_mode_cpu( ...

  9. caffe Python API 之Solver定义

    from caffe.proto import caffe_pb2 s = caffe_pb2.SolverParameter() path='/home/xxx/data/' solver_file ...

随机推荐

  1. Python 源码剖析(四)【LIST对象】

    四.LIST对象 1.PyListObject对象 2.PyListObject的创建与维护 3.PyListObject 对象缓冲池 4.Hack PyListObject 1.PyListObje ...

  2. P3074 [USACO13FEB]牛奶调度Milk Scheduling

    题目描述 Farmer John's N cows (1 <= N <= 10,000) are conveniently numbered 1..N. Each cow i takes ...

  3. [SCOI2008]天平 差分约束

    ---题面--- 题解: 差分约束学得实在是太烂了,,,,QAQ 这里先记下: a - b >= x  ---> a >= b + x     ---->        b - ...

  4. BZOJ3339:Rmq Problem & BZOJ3585 & 洛谷4137:mex——题解

    前者:https://www.lydsy.com/JudgeOnline/problem.php?id=3339 后者: https://www.lydsy.com/JudgeOnline/probl ...

  5. [Leetcode] maximun subarray 最大子数组

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  6. BZOJ3670 [Noi2014]动物园 【KMP计数】

    3670: [Noi2014]动物园 Time Limit: 10 Sec  Memory Limit: 512 MB Submit: 3143  Solved: 1690 [Submit][Stat ...

  7. OLTP与OLAP比较【转】

    OLTP与OLAP的介绍 数据处理大致可以分成两大类:联机事务处理OLTP(on-line transaction processing).联机分析处理OLAP(On-Line Analytical ...

  8. 使用PowerDesigner建模

    一.使用PowerDesigner建模 在数据库概念设计中已经分析了本系统中主要的数据应实体对象,通过这些实体可以得出数据表结构的基本模型,最终实施到数据库中, 形成完整的数据结构.本系统将使用Pow ...

  9. YARN和MapReduce的内存设置参考

    如何确定Yarn中容器Container,Mapreduce相关参数的内存设置,对于初始集群,由于不知道集群的类型(如cpu密集.内存密集)我们需要根据经验提供给我们一个参考配置值,来作为基础的配置. ...

  10. PHP调试的时候出现了警告:

    It is not safe to rely on the system解决方法,其实就是时区设置不正确造成的,本文提供了3种方法来解决这个问题. 实际上,从PHP 5.1.0开始当对使用date() ...