zoukankan      html  css  js  c++  java
  • caffe Python API 之激活函数ReLU

    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"
    }
  • 相关阅读:
    4. ConcurrentHashMap 锁分段机制
    3. 原子变量-CAS算法
    2. 原子变量
    1. volatale 关键字 -内存可见性
    6.8 全局查询日志
    js实现数字分页
    拆箱和装箱
    string与stringbuilder的区别
    C#之out与ref的共性与区别以及用法
    asp.net操作xml(增删查改)
  • 原文地址:https://www.cnblogs.com/houjun/p/9912435.html
Copyright © 2011-2022 走看看