caffe网络配置--各计算层

caffe网络配置--各计算层

卷积层

layer {

 name: "conv1"

 type: "Convolution"

 bottom: "data"

 top: "conv1"

 param {

   lr_mult: 1   //学习率系数  最终学习率=solver中的学习率*lr_mult

  }

 param {

   lr_mult: 2  //若有两个ir_mult:则第一个表示权值学习率;第二个表示偏置项学习率。一般

  }                偏置项学习率是权值学习率2倍。

 convolution_param {

   num_output: 32    //卷积核filter个数

   pad: 2           //默认为0

   kernel_size: 5

   stride: 1

   weight_filler {

     type: "gaussian"        //权值初始化。默认为constant:全0。很多时候用xavier初

     std: 0.0001                 始化,也可设置为gaussian

   }

   bias_filler {

     type: "constant"          //偏置项初始化,constant为全0

   }

  }

}

 

输入:n*c0*w0*h0

输出:n*c1*w1*h1

c1即特征图个数

w1 = (w0+2*pad-kernel_size)/stride+1

h1 = (h0+2*pad-kernel_size)/stride+1

 准确率输出

layer {

 name: "accuracy"

 type: "Accuracy"

 bottom: "ip2"

 bottom: "label"

 top: "accuracy"

 include {

   phase: TEST

  }

}

 分类层

layer {

 name: "loss"

 type: "SoftmaxWithLoss"  //输出loss

 bottom: "ip2"

 bottom: "label"

 top: "loss"

}

 

layer {

 name: "prob"

 type: "Softmax"    //输出概率值

 bottom: "ip2"

 bottom: "label"

 top: "prob"

}

 维度变换层

layer {

 name: "reshape"

 type: "Reshape"    //不改变输入的数据值的大小,仅改变维度

 bottom: "input"

 top: "output"

reshape_param{

  shape{         //0:表示维度不变,-1表示系统自动计算维度。其它值:将原维度变为其它值

    dim:0

    dim:0

    dim:0

    dim: -1

 

}

}

}

原数据为(32*3*28*28)——> shape{0,0,14,-1}——>(32*3*14*56)

 Dropout层

//防止过拟合

layer {

 name: "drop"

 type: "Dropout"   

 bottom: "ip2"    //输入输出为同一层

 top: "ip2"

  dropout_param{

  dropout_ratio:0.5

}

激活函数层

太简单,不做说明

polling层

参考卷积层

猜你喜欢

转载自blog.csdn.net/qq_33993942/article/details/79991795