This repository contains two Python notebooks demonstrating the implementation of triplet and contrastive loss for similarity learning. Triplet and contrastive loss are commonly used in siamese and triplet network architectures for learning similarity and dissimilarity between data points.
triplet_loss.ipynb
: Jupyter notebook containing the implementation of triplet and contrastive loss using TensorFlow/Keras.data/
: Directory containing sample datasets for testing the implementation.
To use the notebook, simply open TripletLoss.ipynb
or Contrasive Loss.ipynb
in Jupyter Notebook or JupyterLab. The notebook contains detailed explanations and code for implementing triplet and contrastive loss, as well as examples of how to use them in training neural networks.
The implementation in the notebook requires the following Python libraries:
- pytorch
- NumPy
- Matplotlib
You can install the required dependencies using the following command:
pip install pytorch numpy matplotlib
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to contribute to this project by opening issues or pull requests.
This implementation is based on the following research papers:
- Schroff, F., Kalenichenko, D., & Philbin, J. (2015). FaceNet: A Unified Embedding for Face Recognition and Clustering.
- Hadsell, R., Chopra, S., & LeCun, Y. (2006). Dimensionality Reduction by Learning an Invariant Mapping.
Yasaman Haghbin