Simultaneous Feature Learning
and Hash Coding with Deep Neural Networks
这篇paper也是和深度hash相关的,该论文分为三个部分,如下图所示:输入的image这里使用的是三个输入图像,有两个图想属于同一个class,另一个图像和属于另一个class。在试验部分,作者让三个image使用相同的一个网络(当然,还可以让queries使用一个net,而similar images和dissimilar images共享一个Net)达到了比较好的效果。中间一些列的卷积层其实是network-in-network的一个改变版本:在每一个卷积层的后面插入一个1*1的卷积核作为一个线性的转换器,把fc层改为average pooling,最终的输出feature map大小是50*#bits*1*1。简单点而看下面的divide-and-encode中有n个bits,每个bits中有50个神经元,然后这50个神经元在concatenate成为一个神经元,这样50*bits*1*1就变成了bits*1*1*1,也就是bits个神经元,然后使用的triple loss进行参数学习。
最后得到的50个神经元在经过一个piece-wise 阈值函数如下:
中间的网络架构如下:
divide-and-encode 的caffe版本实现如下:(如有错误,请不吝赐教)
layer{
name: "pool4"
type: "Pooling"
bottom: "conv4_1"
top: "pool4"
pooling_param{
pool: AVERAGE
kernel_size: 3
stride: 2
}
}
layer{
name: "spilt"
type: "Slice"
bottom: "pool4"
top: "slice_1"
top: "slice_2"
top: "slice_3"
top: "slice_4"
slice_param{
slice_dim:1
slice_point:50
slice_point:100
slice_point:150
}
}
layer {
name: "ip_1"
type: "InnerProduct"
bottom: "slice_1"
top: "hash_1"
inner_product_param {
num_output: 1
}
}
layer {
name: "ip_2"
type: "InnerProduct"
bottom: "slice_2"
top: "hash_2"
inner_product_param {
num_output: 1
}
}
layer {
name: "ip_3"
type: "InnerProduct"
bottom: "slice_3"
top: "hash_3"
inner_product_param {
num_output: 1
}
}
layer {
name: "ip_4"
type: "InnerProduct"
bottom: "slice_4"
top: "hash_4"
inner_product_param {
num_output: 1
}
}
layer {
name: "concat"
type: "Concat"
bottom: "hash_1"
bottom: "hash_2"
bottom: "hash_3"
bottom: "hash_4"
top: "concat"
concat_param {
concat_dim: 1
}
}
layer {
name: "triplet"
type: "Slice"
bottom: "concat"
top: "query"
top: "positive"
top: "negetive"
slice_param {
axis: 0
slice_point: 16
slice_point: 32
}
}
layer {
name: "pos_sim"
type: "DotProductSimilarity"
bottom: "query"
bottom: "positive"
top: "pos_sim"
}
layer {
name: "neg_sim"
type: "DotProductSimilarity"
bottom: "query"
bottom: "negetive"
top: "neg_sim"
}
layer {
name: "loss"
type: "PairwiseRankingLoss"
bottom: "pos_sim"
bottom: "neg_sim"
top: "loss"
triplet_loss_param {
margin: 1
}
}