如何实现在prototxt 中实现多通道呢?

或者是一次性输入3张图片呢?与Triplet loss 相关
已邀请:
补充一下:Slice层的使用,把数据分成了两部分

xinmiao

赞同来自:

本内容作者仅授权给CaffeCN社区(caffecn.cn)使用,如需转载请附上内容来源说明。

可以看一下siamese network的实现,

siamese.jpg


输入是两张图像,分别进入两个网络,所以在prototxt中,
////////////////////////////第一个通路
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param {
lr_mult: 1
}
param {
lr_mult: 2
}
convolution_param {
num_output: 20
kernel_size: 5
stride: 1
}
}


......


layer {
name: "feat"
type: "InnerProduct"
bottom: "ip2"
top: "feat"
param {
name: "feat_w"
lr_mult: 1
}
param {
name: "feat_b"
lr_mult: 2
}
inner_product_param {
num_output: 2
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

//////////////////////////////// 第二个通路
layer {
name: "conv1_p"
type: "Convolution"
bottom: "data_p"
top: "conv1_p"
param {
name: "conv1_w"
lr_mult: 1
decay_mult: 1
}
param {
name: "conv1_b"
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 96
kernel_size: 11
stride: 4
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}

........

layer {
name: "feat_p"
type: "InnerProduct"
bottom: "ip2_p"
top: "feat_p"
param {
name: "feat_w"
lr_mult: 1
}
param {
name: "feat_b"
lr_mult: 2
}
inner_product_param {
num_output: 2
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

/////////////////////////// 两个通路得到的feature做contrast
layer {
name: "loss"
type: "ContrastiveLoss"
bottom: "feat"
bottom: "feat_p"
bottom: "sim"
top: "loss"
contrastive_loss_param {
margin: 1
}
}

happynear - https://github.com/happynear

赞同来自:

官方的siamese结构太臃肿,可以参考一下我写的deepid2网络,输入2个data layer,然后用concat layer合并,输入同一个网络中,最后再用slice layer将特征分开,输入contrastive loss layer。
 
https://github.com/happynear/F ... totxt

要回复问题请先登录注册