caffe rpn layer 中的 reshape layer


Reshape層:(改變blob的形狀,N,C,W,H)

 

    layer {  
        name: "reshape"  
        type: "Reshape"  
        bottom: "input"  
        top: "output"  
        reshape_param {  
          shape {  
            dim: 0  # copy the dimension from below  
            dim: 2  
            dim: 3  
            dim: -1 # infer it from the other dimensions  
          }  
        }  
      }  
      
    #有一個可選的參數組shape, 用於指定blob數據的各維的值(blob是一個四維的數據:n*c*w*h)。  
      
    #dim:0  表示維度不變,即輸入和輸出是相同的維度。  
      
    #dim:2 或 dim:3 將原來的維度變成2或3  
      
    #dim:-1 表示由系統自動計算維度。數據的總量不變,系統會根據blob數據的其它三維來自動計算當前維的維度值 。  
      
    #假設原數據為:32*3*28*28, 表示32張3通道的28*28的彩色圖片  
    #   shape {  
    #   dim: 0  32-32  
    #   dim: 0  3-3  
    #   dim: 14 28-14  
    #   dim: -1 #讓其推斷出此數值  
    #   }  
      
    #輸出數據為:32*3*14*56  

 

 

 

Reshape layer只改變輸入數據的維度,但內容不變,也沒有數據復制的過程,與Flatten layer類似。

輸出維度由reshape_param 指定,正整數直接指定維度大小,下面兩個特殊的值:

  • 0 => 表示copy the respective dimension of the bottom layer,復制輸入相應維度的值。
  • -1 => 表示infer this from the other dimensions,根據其他維度自動推測維度大小。reshape_param中至多只能有一個-1。

再舉一個例子:如果指定reshape_param參數為:{ shape { dim: 0 dim: -1 } } ,那么輸出和Flattening layer的輸出是完全一樣的。

Flatten層和Reshape層想似:

類型:Flatten

Flatten層是把一個輸入的大小為n * c * h * w變成一個簡單的向量,其大小為 n * (c*h*w)


免責聲明!

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



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