SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
Siamese Networks
Textual Record Matching
By Nick McClure
@nfmcclure
Outline
● Motivation
– Why are siamese networks useful?
– Why should we care?
– What are the benefits?
● Structure and Loss
– What are they?
– How does the loss work?
● Use Cases
● Address Matching Example Code
Motivation
● Neural Networks can have unintentional behaviors.
– Outliers
– Model Bias
– Unexplainable results
● Siamese Networks impose a structure that helps
combat these problems.
● Siamese Networks allow us to use more data points
than we would have in other common cases.
– Allow us to use relationships between data points!
Blue Red
Structural Definition
● Siamese networks train a similarity measure
between labeled points.
● Two input data points (textual embeddings,
images, etc…) are run simultaneously through a
neural network and are both mapped to a vector
of shape Nx1.
● Then a standard numerical function can measure
the distance between the vectors (e.g. the cosine
distance).
Structural Definition
Input A Input B
Neural Network
Architecture
Neural Network
Architecture
Vector A Output Vector B Output
Cosine Similarity
-1<=output<=1
Same Parameters
Same Structure
Training Dataset
● Siamese Networks must be trained on data that has two
inputs and a target similarity.
– [‘input a1’, ‘input a2’, 1]
– [‘input a2’, ‘input a3’, 1]
– [‘input a2’, ‘input b1’, -1]
– …
● There must be similar inputs (+1) and dissimilar inputs (-1).
● Most studies have shown that the ratio of dissimilar to
similar is optimal around:
– Between 2:1 and 10:1.
– This depends on the problem and specificity of the model needed.
Training Dataset
● Since we have to generate similar and dissimilar pairs, the
actual amount of training data is quite higher than normal.
● For example, in the UCI machine learning data set of
spam/ham text messages, there are 656 observations, 577
are ham and only 79 are spam.
● With the siamese architecture, we can consider up to 79
choose 2 = 3,081 similar spam comparisons and 577
choose 2 = 166,176 similar ham comparisons, while
having 45,583 total dissimilar comparisons!!!
Dealing with New Data
● Another benefit is that siamese similarity networks
generalize to inputs and outputs that have never been
seen before.
– This makes sense when comparing to how a person
can make predictions on unseen instances and events.
Help Explain Results
● With siamese networks, we can always list the nearest
points in the output-vector space. Because of this, we can
say that a data point has a specific label because it is
nearest to a set of points.
● This type of explanation does not depend on how
complicated the internal structure is.
Siamese Loss Function: Contrastive Loss
● The loss function is a combination of a similar-loss
(L+) and dissimilar-loss (L-).
How Does the Backpropagation Work?
● Siamese networks are constrained to have the same
parameters in both sides of the network.
● To train the network, a pair of output vectors needs to be
either closer together (similar) or further apart (dissimilar).
● It is standard to average the gradients of the two ‘sides’
before performing the gradient update step.
Potential Use Cases
● Natural Language Processing:
– Ontology creation: How similar are words/phrases?
– Job Title Matching: ‘VP of HR’ == ‘V.P. of People’
– Topic matching: Which topic is this phrase referring to?
● Others:
– Image recognition
– Image search
– Signature/Speech recognition
Address Matching!
● Input addresses can have typos. We need to be
able to process these addresses and match
them to a best address from a canonical truth
set.
● E.g. ‘123 MaiinSt’ matches to ‘123 Main St’.
– Why? Fat fingers, image→text translation errors,
encoding errors, etc...
● Our siamese network will be a bidirectional
LSTM with a fully connected layer on the top.
Address Matching!
TensorFlow Demo!
Here: https://github.com/nfmcclure/tensorflow_cookbook
Navigate to Chapter 09: RNNs, then Section 06: Training a Siamese Similarity Measure
Conclusions and Summary
● Advantages:
– Can predict out-of-training-set data.
– Makes use of relationships, using more data.
– Explainable results, regardless of network complexity.
● Disadvantages:
– More computationally intensive (precomputation helps however).
– More hyperparameters and fine-tuning necessary.
– Generally, more training needed.
● When to use:
– Want to exploit relationships between data points.
– Can easily label ‘similar’ and ‘dissimilar’ points.
● When not to use:
Further References
● Signature Verification with fully connected siamese newtworks, 1995, Yann
LeCun, et. al., Bell Labs,
http://papers.nips.cc/paper/769-signature-verification-using-a-siamese-time-
delay-neural-network.pdf
● Attention based CNN for sentence similarity, 2015,
https://arxiv.org/pdf/1512.05193v2.pdf
● Learning text similarities with siamese RNNs, 2016,
http://anthology.aclweb.org/W16-1617
● Sketch-based Image Retrieval via Siamese CNNs, 2016,
http://qugank.github.io/papers/ICIP16.pdf

Contenu connexe

Tendances

PR-231: A Simple Framework for Contrastive Learning of Visual Representations
PR-231: A Simple Framework for Contrastive Learning of Visual RepresentationsPR-231: A Simple Framework for Contrastive Learning of Visual Representations
PR-231: A Simple Framework for Contrastive Learning of Visual RepresentationsJinwon Lee
 
Deep Dive into Hyperparameter Tuning
Deep Dive into Hyperparameter TuningDeep Dive into Hyperparameter Tuning
Deep Dive into Hyperparameter TuningShubhmay Potdar
 
Extreme learning machine:Theory and applications
Extreme learning machine:Theory and applicationsExtreme learning machine:Theory and applications
Extreme learning machine:Theory and applicationsJames Chou
 
Transfer Learning: An overview
Transfer Learning: An overviewTransfer Learning: An overview
Transfer Learning: An overviewjins0618
 
Image Segmentation Using Deep Learning : A survey
Image Segmentation Using Deep Learning : A surveyImage Segmentation Using Deep Learning : A survey
Image Segmentation Using Deep Learning : A surveyNUPUR YADAV
 
Radial basis function network ppt bySheetal,Samreen and Dhanashri
Radial basis function network ppt bySheetal,Samreen and DhanashriRadial basis function network ppt bySheetal,Samreen and Dhanashri
Radial basis function network ppt bySheetal,Samreen and Dhanashrisheetal katkar
 
Introduction to Recurrent Neural Network
Introduction to Recurrent Neural NetworkIntroduction to Recurrent Neural Network
Introduction to Recurrent Neural NetworkKnoldus Inc.
 
Activation function
Activation functionActivation function
Activation functionAstha Jain
 
Feedforward neural network
Feedforward neural networkFeedforward neural network
Feedforward neural networkSopheaktra YONG
 
Vanishing & Exploding Gradients
Vanishing & Exploding GradientsVanishing & Exploding Gradients
Vanishing & Exploding GradientsSiddharth Vij
 
Back propagation
Back propagationBack propagation
Back propagationNagarajan
 
Introduction to CNN
Introduction to CNNIntroduction to CNN
Introduction to CNNShuai Zhang
 
Deep Learning - CNN and RNN
Deep Learning - CNN and RNNDeep Learning - CNN and RNN
Deep Learning - CNN and RNNAshray Bhandare
 

Tendances (20)

PR-231: A Simple Framework for Contrastive Learning of Visual Representations
PR-231: A Simple Framework for Contrastive Learning of Visual RepresentationsPR-231: A Simple Framework for Contrastive Learning of Visual Representations
PR-231: A Simple Framework for Contrastive Learning of Visual Representations
 
Deep Dive into Hyperparameter Tuning
Deep Dive into Hyperparameter TuningDeep Dive into Hyperparameter Tuning
Deep Dive into Hyperparameter Tuning
 
Extreme learning machine:Theory and applications
Extreme learning machine:Theory and applicationsExtreme learning machine:Theory and applications
Extreme learning machine:Theory and applications
 
Transfer Learning: An overview
Transfer Learning: An overviewTransfer Learning: An overview
Transfer Learning: An overview
 
Image Segmentation Using Deep Learning : A survey
Image Segmentation Using Deep Learning : A surveyImage Segmentation Using Deep Learning : A survey
Image Segmentation Using Deep Learning : A survey
 
Perceptron
PerceptronPerceptron
Perceptron
 
Radial basis function network ppt bySheetal,Samreen and Dhanashri
Radial basis function network ppt bySheetal,Samreen and DhanashriRadial basis function network ppt bySheetal,Samreen and Dhanashri
Radial basis function network ppt bySheetal,Samreen and Dhanashri
 
Introduction to Recurrent Neural Network
Introduction to Recurrent Neural NetworkIntroduction to Recurrent Neural Network
Introduction to Recurrent Neural Network
 
Hopfield Networks
Hopfield NetworksHopfield Networks
Hopfield Networks
 
04 Multi-layer Feedforward Networks
04 Multi-layer Feedforward Networks04 Multi-layer Feedforward Networks
04 Multi-layer Feedforward Networks
 
Activation function
Activation functionActivation function
Activation function
 
Feedforward neural network
Feedforward neural networkFeedforward neural network
Feedforward neural network
 
Perceptron & Neural Networks
Perceptron & Neural NetworksPerceptron & Neural Networks
Perceptron & Neural Networks
 
Vanishing & Exploding Gradients
Vanishing & Exploding GradientsVanishing & Exploding Gradients
Vanishing & Exploding Gradients
 
neural networks
neural networksneural networks
neural networks
 
Back propagation
Back propagationBack propagation
Back propagation
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
 
Introduction to CNN
Introduction to CNNIntroduction to CNN
Introduction to CNN
 
Autoencoder
AutoencoderAutoencoder
Autoencoder
 
Deep Learning - CNN and RNN
Deep Learning - CNN and RNNDeep Learning - CNN and RNN
Deep Learning - CNN and RNN
 

Similaire à Siamese networks

Getting started with Machine Learning
Getting started with Machine LearningGetting started with Machine Learning
Getting started with Machine LearningGaurav Bhalotia
 
Machine Learning in the Financial Industry
Machine Learning in the Financial IndustryMachine Learning in the Financial Industry
Machine Learning in the Financial IndustrySubrat Panda, PhD
 
Learning from similarity and information extraction from structured documents...
Learning from similarity and information extraction from structured documents...Learning from similarity and information extraction from structured documents...
Learning from similarity and information extraction from structured documents...Infrrd
 
Feature engineering mean encodings
Feature engineering   mean encodingsFeature engineering   mean encodings
Feature engineering mean encodingsChode Amarnath
 
Machine Learning Unit 1 Semester 3 MSc IT Part 2 Mumbai University
Machine Learning Unit 1 Semester 3  MSc IT Part 2 Mumbai UniversityMachine Learning Unit 1 Semester 3  MSc IT Part 2 Mumbai University
Machine Learning Unit 1 Semester 3 MSc IT Part 2 Mumbai UniversityMadhav Mishra
 
Model Evaluation in the land of Deep Learning
Model Evaluation in the land of Deep LearningModel Evaluation in the land of Deep Learning
Model Evaluation in the land of Deep LearningPramit Choudhary
 
Machine Learning, Deep Learning and Data Analysis Introduction
Machine Learning, Deep Learning and Data Analysis IntroductionMachine Learning, Deep Learning and Data Analysis Introduction
Machine Learning, Deep Learning and Data Analysis IntroductionTe-Yen Liu
 
Machine Learning 2 deep Learning: An Intro
Machine Learning 2 deep Learning: An IntroMachine Learning 2 deep Learning: An Intro
Machine Learning 2 deep Learning: An IntroSi Krishan
 
notes as .ppt
notes as .pptnotes as .ppt
notes as .pptbutest
 
Hacking Predictive Modeling - RoadSec 2018
Hacking Predictive Modeling - RoadSec 2018Hacking Predictive Modeling - RoadSec 2018
Hacking Predictive Modeling - RoadSec 2018HJ van Veen
 
Machine learning for IoT - unpacking the blackbox
Machine learning for IoT - unpacking the blackboxMachine learning for IoT - unpacking the blackbox
Machine learning for IoT - unpacking the blackboxIvo Andreev
 
Deep Learning For Practitioners, lecture 2: Selecting the right applications...
Deep Learning For Practitioners,  lecture 2: Selecting the right applications...Deep Learning For Practitioners,  lecture 2: Selecting the right applications...
Deep Learning For Practitioners, lecture 2: Selecting the right applications...ananth
 
Deep learning Introduction and Basics
Deep learning  Introduction and BasicsDeep learning  Introduction and Basics
Deep learning Introduction and BasicsNitin Mishra
 
Semantic Equivalence of e-Commerce Queries
Semantic Equivalence of e-Commerce QueriesSemantic Equivalence of e-Commerce Queries
Semantic Equivalence of e-Commerce QueriesDaniel Tunkelang
 

Similaire à Siamese networks (20)

Lecture 1
Lecture 1Lecture 1
Lecture 1
 
lec1.ppt
lec1.pptlec1.ppt
lec1.ppt
 
ML.pdf
ML.pdfML.pdf
ML.pdf
 
Getting started with Machine Learning
Getting started with Machine LearningGetting started with Machine Learning
Getting started with Machine Learning
 
Machine Learning in the Financial Industry
Machine Learning in the Financial IndustryMachine Learning in the Financial Industry
Machine Learning in the Financial Industry
 
Learning from similarity and information extraction from structured documents...
Learning from similarity and information extraction from structured documents...Learning from similarity and information extraction from structured documents...
Learning from similarity and information extraction from structured documents...
 
CSSC ML Workshop
CSSC ML WorkshopCSSC ML Workshop
CSSC ML Workshop
 
Feature engineering mean encodings
Feature engineering   mean encodingsFeature engineering   mean encodings
Feature engineering mean encodings
 
Machine Learning Unit 1 Semester 3 MSc IT Part 2 Mumbai University
Machine Learning Unit 1 Semester 3  MSc IT Part 2 Mumbai UniversityMachine Learning Unit 1 Semester 3  MSc IT Part 2 Mumbai University
Machine Learning Unit 1 Semester 3 MSc IT Part 2 Mumbai University
 
Model Evaluation in the land of Deep Learning
Model Evaluation in the land of Deep LearningModel Evaluation in the land of Deep Learning
Model Evaluation in the land of Deep Learning
 
Machine Learning, Deep Learning and Data Analysis Introduction
Machine Learning, Deep Learning and Data Analysis IntroductionMachine Learning, Deep Learning and Data Analysis Introduction
Machine Learning, Deep Learning and Data Analysis Introduction
 
Facial recognition
Facial recognitionFacial recognition
Facial recognition
 
Machine Learning 2 deep Learning: An Intro
Machine Learning 2 deep Learning: An IntroMachine Learning 2 deep Learning: An Intro
Machine Learning 2 deep Learning: An Intro
 
notes as .ppt
notes as .pptnotes as .ppt
notes as .ppt
 
Hacking Predictive Modeling - RoadSec 2018
Hacking Predictive Modeling - RoadSec 2018Hacking Predictive Modeling - RoadSec 2018
Hacking Predictive Modeling - RoadSec 2018
 
Machine learning for IoT - unpacking the blackbox
Machine learning for IoT - unpacking the blackboxMachine learning for IoT - unpacking the blackbox
Machine learning for IoT - unpacking the blackbox
 
Deep Learning For Practitioners, lecture 2: Selecting the right applications...
Deep Learning For Practitioners,  lecture 2: Selecting the right applications...Deep Learning For Practitioners,  lecture 2: Selecting the right applications...
Deep Learning For Practitioners, lecture 2: Selecting the right applications...
 
Deep learning Introduction and Basics
Deep learning  Introduction and BasicsDeep learning  Introduction and Basics
Deep learning Introduction and Basics
 
Nn kb
Nn kbNn kb
Nn kb
 
Semantic Equivalence of e-Commerce Queries
Semantic Equivalence of e-Commerce QueriesSemantic Equivalence of e-Commerce Queries
Semantic Equivalence of e-Commerce Queries
 

Dernier

Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...amitlee9823
 

Dernier (20)

Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 

Siamese networks

  • 1. Siamese Networks Textual Record Matching By Nick McClure @nfmcclure
  • 2. Outline ● Motivation – Why are siamese networks useful? – Why should we care? – What are the benefits? ● Structure and Loss – What are they? – How does the loss work? ● Use Cases ● Address Matching Example Code
  • 3. Motivation ● Neural Networks can have unintentional behaviors. – Outliers – Model Bias – Unexplainable results ● Siamese Networks impose a structure that helps combat these problems. ● Siamese Networks allow us to use more data points than we would have in other common cases. – Allow us to use relationships between data points! Blue Red
  • 4. Structural Definition ● Siamese networks train a similarity measure between labeled points. ● Two input data points (textual embeddings, images, etc…) are run simultaneously through a neural network and are both mapped to a vector of shape Nx1. ● Then a standard numerical function can measure the distance between the vectors (e.g. the cosine distance).
  • 5. Structural Definition Input A Input B Neural Network Architecture Neural Network Architecture Vector A Output Vector B Output Cosine Similarity -1<=output<=1 Same Parameters Same Structure
  • 6. Training Dataset ● Siamese Networks must be trained on data that has two inputs and a target similarity. – [‘input a1’, ‘input a2’, 1] – [‘input a2’, ‘input a3’, 1] – [‘input a2’, ‘input b1’, -1] – … ● There must be similar inputs (+1) and dissimilar inputs (-1). ● Most studies have shown that the ratio of dissimilar to similar is optimal around: – Between 2:1 and 10:1. – This depends on the problem and specificity of the model needed.
  • 7. Training Dataset ● Since we have to generate similar and dissimilar pairs, the actual amount of training data is quite higher than normal. ● For example, in the UCI machine learning data set of spam/ham text messages, there are 656 observations, 577 are ham and only 79 are spam. ● With the siamese architecture, we can consider up to 79 choose 2 = 3,081 similar spam comparisons and 577 choose 2 = 166,176 similar ham comparisons, while having 45,583 total dissimilar comparisons!!!
  • 8. Dealing with New Data ● Another benefit is that siamese similarity networks generalize to inputs and outputs that have never been seen before. – This makes sense when comparing to how a person can make predictions on unseen instances and events.
  • 9. Help Explain Results ● With siamese networks, we can always list the nearest points in the output-vector space. Because of this, we can say that a data point has a specific label because it is nearest to a set of points. ● This type of explanation does not depend on how complicated the internal structure is.
  • 10. Siamese Loss Function: Contrastive Loss ● The loss function is a combination of a similar-loss (L+) and dissimilar-loss (L-).
  • 11. How Does the Backpropagation Work? ● Siamese networks are constrained to have the same parameters in both sides of the network. ● To train the network, a pair of output vectors needs to be either closer together (similar) or further apart (dissimilar). ● It is standard to average the gradients of the two ‘sides’ before performing the gradient update step.
  • 12. Potential Use Cases ● Natural Language Processing: – Ontology creation: How similar are words/phrases? – Job Title Matching: ‘VP of HR’ == ‘V.P. of People’ – Topic matching: Which topic is this phrase referring to? ● Others: – Image recognition – Image search – Signature/Speech recognition
  • 13. Address Matching! ● Input addresses can have typos. We need to be able to process these addresses and match them to a best address from a canonical truth set. ● E.g. ‘123 MaiinSt’ matches to ‘123 Main St’. – Why? Fat fingers, image→text translation errors, encoding errors, etc... ● Our siamese network will be a bidirectional LSTM with a fully connected layer on the top.
  • 14. Address Matching! TensorFlow Demo! Here: https://github.com/nfmcclure/tensorflow_cookbook Navigate to Chapter 09: RNNs, then Section 06: Training a Siamese Similarity Measure
  • 15. Conclusions and Summary ● Advantages: – Can predict out-of-training-set data. – Makes use of relationships, using more data. – Explainable results, regardless of network complexity. ● Disadvantages: – More computationally intensive (precomputation helps however). – More hyperparameters and fine-tuning necessary. – Generally, more training needed. ● When to use: – Want to exploit relationships between data points. – Can easily label ‘similar’ and ‘dissimilar’ points. ● When not to use:
  • 16. Further References ● Signature Verification with fully connected siamese newtworks, 1995, Yann LeCun, et. al., Bell Labs, http://papers.nips.cc/paper/769-signature-verification-using-a-siamese-time- delay-neural-network.pdf ● Attention based CNN for sentence similarity, 2015, https://arxiv.org/pdf/1512.05193v2.pdf ● Learning text similarities with siamese RNNs, 2016, http://anthology.aclweb.org/W16-1617 ● Sketch-based Image Retrieval via Siamese CNNs, 2016, http://qugank.github.io/papers/ICIP16.pdf