水表訓練

來源:互聯網
上載者:User

http://caffe.berkeleyvision.org/gathered/examples/mnist.html

問題: lenet 輸出的機率總有一個1 

解決方案:用softmax 前面的一層,然後歸一化到0-1,好像這個問題還是解決不了。

其實我們需要解決兩個問題:

A。輸出機率

B. 去掉一些掃出來的明顯不是數位圖片,不顯示。

現在用前面的一層可以解決輸出的機率的問題,但是因為輸入任何一個圖片就會輸出一個0,1 那麼如果輸入的圖片不是數字,那麼還是會輸出一個比較大的數字。並不能扔掉這些圖片。

問一下GQ 這個問題。(回複:  正樣本的話最大值輸出可以在6000以上,負樣本暫時沒超過3000 ,暫時先做個閾值 把小的去掉,著實不是一個處理的好方法)

我們主要是訓練了三個網路:輸出都是0,1 

1.用最新的caffe-master 下面 examples 下面的mnist。lenet 的prototxt 是這樣的。

name: "LeNet"input: "data"input_shape {  dim: 1  dim: 1  dim: 28  dim: 28}layer {  name: "conv1"  type: "Convolution"  bottom: "data"  top: "conv1"  param {    lr_mult: 1  }  param {    lr_mult: 2  }  convolution_param {    num_output: 20    kernel_size: 5    stride: 1    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }}layer {  name: "pool1"  type: "Pooling"  bottom: "conv1"  top: "pool1"  pooling_param {    pool: MAX    kernel_size: 2    stride: 2  }}layer {  name: "conv2"  type: "Convolution"  bottom: "pool1"  top: "conv2"  param {    lr_mult: 1  }  param {    lr_mult: 2  }  convolution_param {    num_output: 50    kernel_size: 5    stride: 1    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }}layer {  name: "pool2"  type: "Pooling"  bottom: "conv2"  top: "pool2"  pooling_param {    pool: MAX    kernel_size: 2    stride: 2  }}layer {  name: "ip1"  type: "InnerProduct"  bottom: "pool2"  top: "ip1"  param {    lr_mult: 1  }  param {    lr_mult: 2  }  inner_product_param {    num_output: 500    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }}layer {  name: "relu1"  type: "ReLU"  bottom: "ip1"  top: "ip1"}layer {  name: "ip2"  type: "InnerProduct"  bottom: "ip1"  top: "ip2"  param {    lr_mult: 1  }  param {    lr_mult: 2  }  inner_product_param {    num_output: 20    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }}layer {  name: "prob"  type: "Softmax"  bottom: "ip2"  top: "prob"}

2. 在網上找的一個mnist的設定檔。輸入圖片的尺寸是32 *32的


name: "LeNet"input: "data"input_dim: 1input_dim: 1input_dim: 32input_dim: 32layer {  name: "conv1"  type: "Convolution"  bottom: "data"  top: "conv1"  param {    lr_mult: 1  }  param {    lr_mult: 2  }  convolution_param {    num_output: 6    kernel_size: 5    stride: 1    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }}layer {  name: "pool1"  type: "Pooling"  bottom: "conv1"  top: "pool1"  pooling_param {    pool: MAX    kernel_size: 2    stride: 2  }}layer {  name: "conv2"  type: "Convolution"  bottom: "pool1"  top: "conv2"  param {    lr_mult: 1  }  param {    lr_mult: 2  }  convolution_param {    num_output: 16    kernel_size: 10    stride: 1    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }}layer {  name: "ip1"  type: "InnerProduct"  bottom: "conv2"  top: "ip1"  param {    lr_mult: 1  }  param {    lr_mult: 2  }  inner_product_param {    num_output: 120    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }}layer {  name: "relu1"  type: "ReLU"  bottom: "ip1"  top: "ip1"}layer {  name: "ip2"  type: "InnerProduct"  bottom: "ip1"  top: "ip2"  param {    lr_mult: 1  }  param {    lr_mult: 2  }  inner_product_param {    num_output: 84    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }}layer {  name: "relu2"  type: "ReLU"  bottom: "ip2"  top: "ip2"}layer {  name: "ip3"  type: "InnerProduct"  bottom: "ip2"  top: "ip3"  param {    lr_mult: 1  }  param {    lr_mult: 2  }  inner_product_param {    num_output: 20    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }}layer {  name: "prob"  type: "Softmax"  bottom: "ip3"  top: "prob"}

3. 加了均值之後的mnist為lenet2.

需要注意的問題:

A. 在用matlab 提特徵的時候我們要吧prototxt 裡面的數字

input_dim: 1input_dim: 1input_dim: 32input_dim: 32
B. matlab 提特徵的時候,要提那一層的特徵把之後的層全去掉。比如我們想要softmax 之前層的特徵,要把softmax 這一層全去掉。



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.