Caffe图层中的图层 [英] Layers within a layer in Caffe
本文介绍了Caffe图层中的图层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一个自定义损失层,该层将softmax
和sigmoid
激活应用于bottom [0] blob的一部分.
I have a custom loss layer which I wrote, this layer applies softmax
and sigmoid
activation to part of the bottom[0] blob.
Ex: `bottom[0]` is of shape (say): `[20, 7, 7, 50]` (`NHWC` format)
I would like to apply `softmax` to `[20, 7, 7, 25]` (first 25 channels) and
`sigmoid` to `[20, 7, 7, 1]` (just one channel) and the remaining 24 channels are taken in as it is.
如何有效地将内存分配给这两个softmax
和sigmoid
层的输入Blob,并释放该内存?
How do I effectively allocate memory to the input blobs of these two softmax
and sigmoid
layers and also free this memory ?
推荐答案
您可以简单地使用 "Slice"
层在外部,并使用caffe现成"层对输入blob进行切片:
Instead of allocating data internally, you can simply use a "Slice"
layer externally and slice the input blob using caffe "off-the-shelf" layers:
layer {
name: "slice"
type: "Slice"
bottom: "input_to_loss"
top: "to_softmax"
top: "to_sigmoid"
top: "leftovers"
slice_param {
axis: -1 # slice the last axis
slice_point: 25
slice_point: 26
}
}
这篇关于Caffe图层中的图层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文