改进预测函数,使其具有对称性
原来的预测函数是:
其不满足对称性,下面将其改进为具有对称性的预测函数:
二元组和三元组模型的损失函数与原来类似:
方案一:二元组修改doublet_loss
bottom: “flat_fc1” #f(xi)
bottom: “flat_fc2” #f(xj)
bottom: “fc3b” #Wg(xi,xj)
bottom: “fc3bb” #Wg(xj,xi)
bottom: “pairlabel_ci” #随机选取batchsize=300
top: “loss3”
三元组修改 triplet_loss(与二元组类似)
实验结果:loss处于0.5~2区间,不收敛.
方案二:修改linear_contrastive_loss
bottom: “sum_e_f_f”
bottom:”pairlabel_ci”
top:”loss4”
利用caffe自带函数求欧氏距离:euclidean_distance
bottom: “flat_fc1” #f(xi)
bottom: “flat_fc2” #f(xj)
top:”euclidean_distance”
利用elwise求两次加和:
elwise_layer1:
bottom: “fc3b” #Wg(xi,xj)
bottom: “fc3bb” #Wg(xj,xi)
top:”sum_f_f”
elwise_layer2:
bottom: “sum_f_f”
bottom: “euclidean_distance”
top:”sum_e_f_f”
实验结果:
test_net结果(correct):
二元组singleshot:0.092243
三元组singleshot: 0.33753
原代码:
二元组singleshot:0.3543
三元组没测,但应该大于二元组
分析:test_net 还存在问题