任何渠道明智的实施与caffe?

问题描述 投票:0回答:1

谷歌或github我什么都没得到。

到目前为止,我必须将形状为[N,C,H,W]的两个斑点切割为形状为[N,1,H,W]的2 * C斑点,并将新斑点置换为[N,H,W] ,1],然后在新blob上使用内核大小= 1进行池化。并且连接到[N,H,W,C]并最终置换为[N,C,H,W]。

任何良好的渠道明智汇集实施?

caffe
1个回答
0
投票

对我来说,这听起来像不是一个通道明确的池(必须产生一个输出通道),但element-wise MAX操作:

layer {
  name: "input_1"
  type: "Input"
  top: "input_1"
  input_param {
    shape {
      dim: 1
      dim: 2
      dim: 3
      dim: 3
    }
  }
}

layer {
  name: "input_2"
  type: "Input"
  top: "input_2"
  input_param {
    shape {
      dim: 1
      dim: 2
      dim: 3
      dim: 3
    }
  }  
}

layer {
   name: "channel_max"
   type: "Eltwise"
   bottom: "input_1"
   bottom: "input_2"
   top: "channel_max"
   eltwise_param {
      operation: MAX
   }
}

以下代码:

import caffe
import numpy as np


caffe.set_mode_cpu()
net = caffe.Net('net.prototxt', 1)

net.blobs['input_1'].data[...] = np.random.randint(10, size=(1, 2, 3, 3))
net.blobs['input_2'].data[...] = np.random.randint(10, size=(1, 2, 3, 3))

net.forward()
print('Blob #1:')
print(net.blobs['input_1'].data)
print('Blob #2:')
print(net.blobs['input_2'].data)

print('Result:')
print(net.blobs['channel_max'].data)

将两个blob合并为一个具有相同数量的通道,其中填充了要素图的最大值:

Blob #1:
[[[[5. 6. 5.]
   [1. 6. 1.]
   [4. 7. 6.]]

  [[9. 8. 3.]
   [8. 8. 8.]
   [6. 9. 9.]]]]
Blob #2:
[[[[4. 1. 1.]
   [2. 1. 3.]
   [6. 1. 0.]]

  [[3. 8. 7.]
   [8. 2. 4.]
   [2. 8. 1.]]]]
Result:
[[[[5. 6. 5.]
   [2. 6. 3.]
   [6. 7. 6.]]

  [[9. 8. 7.]
   [8. 8. 8.]
   [6. 9. 9.]]]]
© www.soinside.com 2019 - 2024. All rights reserved.