我没有从谷歌或 github 得到任何东西。
到目前为止,我必须将两个形状为 [N,C,H,W] 的 blob 切片为 2*C 个形状为 [N,1,H,W] 的 blob,并将新 blob 置换为 [N,H,W] 形状, 1],然后在新 blob 上使用内核大小 = 1 进行池化。最后连接到 [N,H,W,C] 并置换到 [N,C,H,W]。
有什么好的渠道明智的池化实现吗?
我没有从谷歌或 github 得到任何东西。
到目前为止,我必须将两个形状为 [N,C,H,W] 的 blob 切片为 2*C 个形状为 [N,1,H,W] 的 blob,并将新 blob 置换为 [N,H,W] 形状, 1],然后在新 blob 上使用内核大小 = 1 进行池化。最后连接到 [N,H,W,C] 并置换到 [N,C,H,W]。
有什么好的渠道明智的池化实现吗?
对我来说,这听起来不像是通道方式的池化(它必须产生单个输出通道),而是元素方式的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.]]]]