#195 · Primary category: Deep Learning Frameworks

siamese-triplet

contrastive-loss deep-learning embedding learning-embeddings machine-learning pytorch siamese-network triplet-loss triplet-network

Siamese and triplet networks with online pair/triplet mining in PyTorch

Project last updated:04/29/23

GitHub Stars

3.2K

Forks

629

Contributors

3

License

BSD-3-Clause

Why we included this project

For anyone training embedding models, this is a compact, readable PyTorch reference for siamese and triplet learning. It gives you the network wrappers, the standard contrastive and triplet losses, and online mining that picks hard pairs or triplets from a mini-batch, so the same embeddings get reused instead of recomputed. The MNIST examples and the single fit() training function make the mechanics easy to follow, which is handy when you want to see why the choice of pairs or triplets matters before adopting a heavier framework. The code is short enough to read in one sitting and adapt into your own pipeline. Just keep in mind it was built against PyTorch 0.4, so it is a learning and prototyping resource rather than something to add as a current dependency.

Articles for this project

No articles for this project yet.

To suggest a topic or contribute an article, contact us.

Related projects in this category