caffe中Reshape层

转自:http://blog.csdn.net/wfei101/article/details/78449428

Reshape层(改变blob的形状,N,C,W,H)

[cpp]  view plain  copy
 print ?
  1. layer {  
  2.     name: "reshape"  
  3.     type: "Reshape"  
  4.     bottom: "input"  
  5.     top: "output"  
  6.     reshape_param {  
  7.       shape {  
  8.         dim: 0  # copy the dimension from below  
  9.         dim: 2  
  10.         dim: 3  
  11.         dim: -1 # infer it from the other dimensions  
  12.       }  
  13.     }  
  14.   }  
  15.   
  16. #有一个可选的参数组shape, 用于指定blob数据的各维的值(blob是一个四维的数据:n*c*w*h)。  
  17.   
  18. #dim:0  表示维度不变,即输入和输出是相同的维度。  
  19.   
  20. #dim:2 或 dim:3 将原来的维度变成2或3  
  21.   
  22. #dim:-1 表示由系统自动计算维度。数据的总量不变,系统会根据blob数据的其它三维来自动计算当前维的维度值 。  
  23.   
  24. #假设原数据为:32*3*28*28, 表示32张3通道的28*28的彩色图片  
  25. #   shape {  
  26. #   dim: 0  32-32  
  27. #   dim: 0  3-3  
  28. #   dim: 14 28-14  
  29. #   dim: -1 #让其推断出此数值  
  30. #   }  
  31.   
  32. #输出数据为: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)


  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值