Learning in twin networks can be done with triplet loss or contrastive loss. For learning by triplet loss a baseline vector (anchor image) is compared against a positive vector (truthy image) and a negative vector (falsy image). The negative vector will force learning in the network, while the positive vector will act like a regularizer. For learning by contrastive loss there must be a weight decay to regularize the weights, or some similar operation like a normalization.
A distance metric for a loss function may have the following properties6
In particular, the triplet loss algorithm is often defined with squared Euclidean (which unlike Euclidean, does not have triangle inequality) distance at its core.
The common learning goal is to minimize a distance metric for similar objects and maximize for distinct ones. This gives a loss function like
The most common distance metric used is Euclidean distance, in case of which the loss function can be rewritten in matrix form as
A more general case is where the output vector from the twin network is passed through additional network layers implementing non-linear distance metrics.
On a matrix form the previous is often approximated as a Mahalanobis distance for a linear space as7
This can be further subdivided in at least Unsupervised learning and Supervised learning.
This form also allows the twin network to be more of a half-twin, implementing a slightly different functions
Twin networks have been used in object tracking because of its unique two tandem inputs and similarity measurement. In object tracking, one input of the twin network is user pre-selected exemplar image, the other input is a larger search image, which twin network's job is to locate exemplar inside of search image. By measuring the similarity between exemplar and each part of the search image, a map of similarity score can be given by the twin network. Furthermore, using a Fully Convolutional Network, the process of computing each sector's similarity score can be replaced with only one cross correlation layer.8
After being first introduced in 2016, Twin fully convolutional network has been used in many High-performance Real-time Object Tracking Neural Networks. Like CFnet,9 StructSiam,10 SiamFC-tri,11 DSiam,12 SA-Siam,13 SiamRPN,14 DaSiamRPN,15 Cascaded SiamRPN,16 SiamMask,17 SiamRPN++,18 Deeper and Wider SiamRPN.19
Chicco, Davide (2020), "Siamese neural networks: an overview", Artificial Neural Networks, Methods in Molecular Biology, vol. 2190 (3rd ed.), New York City, New York, USA: Springer Protocols, Humana Press, pp. 73–94, doi:10.1007/978-1-0716-0826-5_3, ISBN 978-1-0716-0826-5, PMID 32804361, S2CID 221144012 978-1-0716-0826-5 ↩
Bromley, Jane; Guyon, Isabelle; LeCun, Yann; Säckinger, Eduard; Shah, Roopak (1994). "Signature verification using a "Siamese" time delay neural network" (PDF). Advances in Neural Information Processing Systems. 6: 737–744. https://papers.neurips.cc/paper_files/paper/1993/file/288cc0ff022877bd3df94bc9360b9c5d-Paper.pdf ↩
Chopra, S.; Hadsell, R.; LeCun, Y. (June 2005). "Learning a Similarity Metric Discriminatively, with Application to Face Verification". 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'05). Vol. 1. pp. 539–546 vol. 1. doi:10.1109/CVPR.2005.202. ISBN 0-7695-2372-2. S2CID 5555257. 0-7695-2372-2 ↩
Taigman, Y.; Yang, M.; Ranzato, M.; Wolf, L. (June 2014). "DeepFace: Closing the Gap to Human-Level Performance in Face Verification". 2014 IEEE Conference on Computer Vision and Pattern Recognition. pp. 1701–1708. doi:10.1109/CVPR.2014.220. ISBN 978-1-4799-5118-5. S2CID 2814088. 978-1-4799-5118-5 ↩
Chatterjee, Moitreya; Luo, Yunan. "Similarity Learning with (or without) Convolutional Neural Network" (PDF). Retrieved 2018-12-07. http://slazebni.cs.illinois.edu/spring17/lec09_similarity.pdf ↩
Chandra, M.P. (1936). "On the generalized distance in statistics" (PDF). Proceedings of the National Institute of Sciences of India. 1. 2: 49–55. http://library.isical.ac.in:8080/jspui/bitstream/123456789/6765/1/Vol02_1936_1_Art05-pcm.pdf ↩
Fully-Convolutional Siamese Networks for Object Tracking arXiv:1606.09549 /wiki/ArXiv_(identifier) ↩
"End-to-end representation learning for Correlation Filter based tracking". https://www.robots.ox.ac.uk/~luca/cfnet.html ↩
"Structured Siamese Network for Real-Time Visual Tracking" (PDF). http://openaccess.thecvf.com/content_ECCV_2018/papers/Yunhua_Zhang_Structured_Siamese_Network_ECCV_2018_paper.pdf ↩
"Triplet Loss in Siamese Network for Object Tracking" (PDF). http://openaccess.thecvf.com/content_ECCV_2018/papers/Xingping_Dong_Triplet_Loss_with_ECCV_2018_paper.pdf ↩
"Learning Dynamic Siamese Network for Visual Object Tracking" (PDF). http://openaccess.thecvf.com/content_ICCV_2017/papers/Guo_Learning_Dynamic_Siamese_ICCV_2017_paper.pdf ↩
"A Twofold Siamese Network for Real-Time Object Tracking" (PDF). http://openaccess.thecvf.com/content_cvpr_2018/papers/He_A_Twofold_Siamese_CVPR_2018_paper.pdf ↩
"High Performance Visual Tracking with Siamese Region Proposal Network" (PDF). http://openaccess.thecvf.com/content_cvpr_2018/papers/Li_High_Performance_Visual_CVPR_2018_paper.pdf ↩
Zhu, Zheng; Wang, Qiang; Li, Bo; Wu, Wei; Yan, Junjie; Hu, Weiming (2018). "Distractor-aware Siamese Networks for Visual Object Tracking". arXiv:1808.06048 [cs.CV]. /wiki/ArXiv_(identifier) ↩
Fan, Heng; Ling, Haibin (2018). "Siamese Cascaded Region Proposal Networks for Real-Time Visual Tracking". arXiv:1812.06148 [cs.CV]. /wiki/ArXiv_(identifier) ↩
Wang, Qiang; Zhang, Li; Bertinetto, Luca; Hu, Weiming; Torr, Philip H. S. (2018). "Fast Online Object Tracking and Segmentation: A Unifying Approach". arXiv:1812.05050 [cs.CV]. /wiki/ArXiv_(identifier) ↩
Li, Bo; Wu, Wei; Wang, Qiang; Zhang, Fangyi; Xing, Junliang; Yan, Junjie (2018). "SiamRPN++: Evolution of Siamese Visual Tracking with Very Deep Networks". arXiv:1812.11703 [cs.CV]. /wiki/ArXiv_(identifier) ↩
Zhang, Zhipeng; Peng, Houwen (2019). "Deeper and Wider Siamese Networks for Real-Time Visual Tracking". arXiv:1901.01660 [cs.CV]. /wiki/ArXiv_(identifier) ↩