caffe模型参数的一些解释

来源:互联网 发布:js shift方法 编辑:程序博客网 时间:2024/05/22 00:26

作者:wjmishuai

出处: http://blog.csdn.net/wjmishuai/article/details/50890214
声明:版权所有,转载请联系作者并注明出处

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. 原始数据是28*28  
  2. 1:数据层:  
  3. layer {  
  4.   name: "mnist"//数据层的名字是mnist  
  5.   type: "Data"//这个层的类型是data  
  6.   top: "data"//产生两个blob,一个是data blob  
  7.   top: "label"//一个是lable blob  
  8.   include {  
  9.     phase: TRAIN  
  10.   }  
  11.   transform_param {  
  12.     scale: 0.00390625//像素归一化  
  13.   }  
  14.   data_param {  
  15.     source: "examples/mnist/mnist_train_lmdb"  
  16.     batch_size: 64  
  17.     backend: LMDB  
  18.   }  
  19. }  
  20. 2:卷积层  
  21. layer {  
  22.   name: "conv1"  
  23.   type: "Convolution"  
  24.   bottom: "data"//获取上一层的data blob  
  25.   top: "conv1"//产生conv1层  
  26.   param {  
  27.     lr_mult: 1//学习率。表示 weight的学习率和slover.pro中的学习率是一致的。  
  28.   }  
  29.   param {  
  30.     lr_mult: 2//表示 bias的学习率是slover.pro中的学习率的2倍。  这样设置会导致更快的收敛  
  31.   }  
  32.   convolution_param {  
  33.     num_output: 20//cov1层将产生输出20个通道  
  34.     kernel_size: 5//卷积核大小是5*5  
  35.     stride: 1//步长是1  
  36.     weight_filler {//权重填充器,使用xavier算法填充weight。根据输入和输出神经元的数量自动确定初始化的规模。  
  37.       type: "xavier"  
  38.     }  
  39.     bias_filler {//偏置填充器,使用constant算法填充bias。是一个常数,默认是0  
  40.       type: "constant"  
  41.     }  
  42.   }  
  43. }  
  44. 3:池化层(避免数据过拟合)  
  45. layer {  
  46.   name: "pool1"  
  47.   type: "Pooling"  
  48.   bottom: "conv1"  
  49.   top: "pool1"  
  50.   pooling_param {  
  51.     pool: MAX//使用MAX进行池化  
  52.     kernel_size: 2//卷积核大小是2*2  
  53.     stride: 2//步长是2  
  54.   }  
  55. }  
  56.   
  57. 4:全连接层  
  58. layer {  
  59.   name: "ip1"  
  60.   type: "InnerProduct"  
  61.   bottom: "pool2"  
  62.   top: "ip1"  
  63.   param {  
  64.     lr_mult: 1  
  65.   }  
  66.   param {  
  67.     lr_mult: 2  
  68.   }  
  69.   inner_product_param {  
  70.     num_output: 500//产生500维的输出数据  
  71.     weight_filler {  
  72.       type: "xavier"  
  73.     }  
  74.     bias_filler {  
  75.       type: "constant"  
  76.     }  
  77.   }  
  78. }  
  79.   
  80. 5:ReLU层(紧跟在全连接层后,目的是节省内存)  
  81. layer {  
  82.   name: "relu1"  
  83.   type: "ReLU"  
  84.   bottom: "ip1"  
  85.   top: "ip1"  
  86. }  
  87.   
  88. ReLU层后紧跟一个InnerProduct层  
  89. layer {  
  90.   name: "ip2"  
  91.   type: "InnerProduct"  
  92.   bottom: "ip1"  
  93.   top: "ip2"  
  94.   param {  
  95.     lr_mult: 1  
  96.   }  
  97.   param {  
  98.     lr_mult: 2  
  99.   }  
  100.   inner_product_param {  
  101.     num_output: 10//因为有10类,所以输出10  
  102.     weight_filler {  
  103.       type: "xavier"  
  104.     }  
  105.     bias_filler {  
  106.       type: "constant"  
  107.     }  
  108.   }  
  109. }  
  110.   
  111. 6:Loss层//不产生任何输出,只是用来计算损失函数的值,用来初始化ip2的gradient   
  112. layer {  
  113.   name: "loss"  
  114.   type: "SoftmaxWithLoss"  
  115.   bottom: "ip2"//需要两个blob,一个是ip2,作为预测用  
  116.   bottom: "label"//来自数据层,作为标签  
  117.   top: "loss"  
  118. }  

0 0
原创粉丝点击