CAFFE:Inner_Product層


在caffe中所謂的Inner_Product(IP) 層即fully_connected (fc)layer,為什么叫ip呢,可能是為了看起來比較優雅吧。。

從CAFFE_ROOT/examples/mnist/lenet.prototxt中截取一段

假設conv2的輸入是256*27*27,那么conv2的輸出即50*22*22,conv2的輸入即pool2的輸入,pool2的輸出為50*11*11,即ip1的輸入

ip1的輸出為500*1*1,那么pool2->ip1的參數個數是多少呢?這里就要理解好什么是fully_connected了,即wTx,x為列向量,w的長度與x相同。

在本文的例子中x的維度為50*11*11,那么pool2->ip1的參數個數為500*50*11*11 。50*11*11即是一個有50個通道大小為11*11的圖片,那么在做

完全卷積的時候,需要把對所有通道一起作卷積,即把圖片轉化成一個50*11*11的向量(理解這一點非常重要

layers {
  name: "conv2"
  type: CONVOLUTION
  bottom: "pool1"
  top: "conv2"
  blobs_lr: 1
  blobs_lr: 2
  convolution_param {
    num_output: 50
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layers {
  name: "pool2"
  type: POOLING
  bottom: "conv2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layers {
  name: "ip1"
  type: INNER_PRODUCT
  bottom: "pool2"
  top: "ip1"
  blobs_lr: 1
  blobs_lr: 2
  inner_product_param {
    num_output: 500
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM