工厂模式-CaffeNet训练

来源:互联网 发布:php解压缩zip代码 编辑:程序博客网 时间:2024/06/11 05:28

参考链接:http://blog.csdn.net/lingerlanlan/article/details/32329761

RNN神经网络:http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/detection.ipynb

官方链接:http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/classification.ipynb

参考链接:http://suanfazu.com/t/caffe-shen-du-xue-xi-kuang-jia-shang-shou-jiao-cheng/281/3


模型定义中有一点比较容易被误解,信号在有向图中是自下而上流动的,并不是自上而下。

层的结构定义如下:

       1 name:层名称 2 type:层类型 3 top:出口 4 bottom:入口 

Each layer type defines three critical computations: setup, forward, andbackward.

  • Setup: initialize the layer and its connections once at model initialization.
  • Forward: given input from bottom compute the output and send to the top.
  • Backward: given the gradient w.r.t. the top output compute the gradient w.r.t. to the input and send to the bottom. A layer with parameters computes the gradient w.r.t. to its parameters and stores it internally.

/home/wishchin/caffe-master/examples/hdf5_classification/train_val2.prototxt

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. name: "LogisticRegressionNet"  
  2. layer {  
  3.   name: "data"  
  4.   type: "HDF5Data"  
  5.   top: "data"  
  6.   top: "label"  
  7.   include {  
  8.     phase: TRAIN  
  9.   }  
  10.   hdf5_data_param {  
  11.     source: "hdf5_classification/data/train.txt"  
  12.     batch_size: 10  
  13.   }  
  14. }  
  15. layer {  
  16.   name: "data"  
  17.   type: "HDF5Data"  
  18.   top: "data"  
  19.   top: "label"  
  20.   include {  
  21.     phase: TEST  
  22.   }  
  23.   hdf5_data_param {  
  24.     source: "hdf5_classification/data/test.txt"  
  25.     batch_size: 10  
  26.   }  
  27. }  
  28. layer {  
  29.   name: "fc1"  
  30.   type: "InnerProduct"  
  31.   bottom: "data"  
  32.   top: "fc1"  
  33.   param {  
  34.     lr_mult: 1  
  35.     decay_mult: 1  
  36.   }  
  37.   param {  
  38.     lr_mult: 2  
  39.     decay_mult: 0  
  40.   }  
  41.   inner_product_param {  
  42.     num_output: 40  
  43.     weight_filler {  
  44.       type: "gaussian"  
  45.       std: 0.01  
  46.     }  
  47.     bias_filler {  
  48.       type: "constant"  
  49.       value: 0  
  50.     }  
  51.   }  
  52. }  
  53. layer {  
  54.   name: "relu1"  
  55.   type: "ReLU"  
  56.   bottom: "fc1"  
  57.   top: "fc1"  
  58. }  
  59. layer {  
  60.   name: "fc2"  
  61.   type: "InnerProduct"  
  62.   bottom: "fc1"  
  63.   top: "fc2"  
  64.   param {  
  65.     lr_mult: 1  
  66.     decay_mult: 1  
  67.   }  
  68.   param {  
  69.     lr_mult: 2  
  70.     decay_mult: 0  
  71.   }  
  72.   inner_product_param {  
  73.     num_output: 2  
  74.     weight_filler {  
  75.       type: "gaussian"  
  76.       std: 0.01  
  77.     }  
  78.     bias_filler {  
  79.       type: "constant"  
  80.       value: 0  
  81.     }  
  82.   }  
  83. }  
  84. layer {  
  85.   name: "loss"  
  86.   type: "SoftmaxWithLoss"  
  87.   bottom: "fc2"  
  88.   bottom: "label"  
  89.   top: "loss"  
  90. }  
  91. layer {  
  92.   name: "accuracy"  
  93.   type: "Accuracy"  
  94.   bottom: "fc2"  
  95.   bottom: "label"  
  96.   top: "accuracy"  
  97.   include {  
  98.     phase: TEST  
  99.   }  
  100. }  

关于参数与结果的关系多次训练效果一直在0.7,后来改动了全链接层的初始化参数。高斯分布的标准差由0.001改为0.0001,就是调小了。 我的结果有点相似。

0 0
原创粉丝点击