在上一篇博文中,我们一起实现了MatchNet 的feature 部分,然后双塔顶端,分别是两层 全连接层,现在我们就按照 match net的结构,把分离的全连接 变成整体- metric network.
输入的数据是 ip1和ip1_p,我们需要把数据。
layer {
name: "ip1"
type: "InnerProduct"
bottom: "pool2"
top: "ip1"
param {
name: "ip1_w"
lr_mult: 1
}
param {
name: "ip1_b"
lr_mult: 2
}
inner_product_param {
num_output: 500
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}layer {
name: "ip1_p"
type: "InnerProduct"
bottom: "pool2_p"
top: "ip1_p"
param { name: "ip1_w" lr_mult: 1 }
param { name: "ip1_b" lr_mult: 2 }
inner_product_param {
num_output: 500 weight_filler { type: "xavier" }
bias_filler { type: "constant" }
}
}
#####使用contat 把数据可以做成一个整体
layers {
name: "concat"
bottom: "ip1"
bottom: "ip1_p"
top: "concat"
type: CONCAT
concat_param {
concat_dim: 1
}
}
layer{
name:"ip2"
type:"InnerProduct"
bottom:"concat"
top:"ip2"
param {
name:"ip2_w"
lr_mult:1
}
param {
name:"ip2_b" lr_mult:2}
inner_product_param {
num_output: 500 weight_filler { type: "xavier" } bias_filler {
type: "constant" }}
}
通过上面的代码,我们就完成了matric net.然后的任务是选择一个 新的loss function.
值得一提的是:这个网络是在和mnist siamese数据集类型相适应的,我们不能用matchNet论文中提供的数据集格式 来训练。原因是 论文的 数据集 是 64 * 1* 64*64, 他采用sampling 来处理出入数据,然后给 siamese网络,但是他们没有提供相关信息。
所以下面我们只能自己制作数据集了。
_______________________________________________________________________________________________
感谢你的资助,这将帮助我更新文章,写出更多的有别于其他博客的博文。
版权声明:本文为aaron121211原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。