Coder Social home page Coder Social logo

ml-lab / magnetloss-pytorch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vithursant/magnetloss-pytorch

0.0 2.0 0.0 2.25 MB

PyTorch implementation of a deep metric learning technique called "Magnet Loss" from Facebook AI Research (FAIR).

License: MIT License

Python 99.29% Shell 0.71%

magnetloss-pytorch's Introduction

Magnet-Loss-PyTorch

PyTorch implementation of the Magnet Loss for Deep Metric Learning, based on the following paper:

Table of Contents

Installation

The program requires the following dependencies (easy to install using pip, Ananconda or Docker):

  • python (tested on 2.7 and 3.6)
  • pytorch (tested with v0.3 and v0.3.1 with CUDA 8.0/9.0)
  • numpy
  • matplotlib
  • seaborn
  • pandas
  • tqdm
  • pillow
  • sklearn
  • scipy
  • visdom

Anaconda

Anaconda: Installation

To install MagnetLoss in an Anaconda environment:

(Python 2.7) conda env create -f pytorch-2p7-cuda80.yml
(Python 3.6) conda env create -f pytorch-3p6-cuda80.yml

To activate Anaconda environment:

(Python 2.7) source activate magnet-loss-py27-env
(Python 3.6) source activate magnet-loss-py36-env

Anaconda: Train

Train ConvNet with Magnet Loss on the local machine using MNIST dataset:

python magnet_loss_test.py --lr 1e-4 --batch-size 64 --mnist --dml

Docker GPU Training

Prerequisites:

  1. Docker installed on your machine. If you don't have Docker installed already, then go here to Docker Setup
  2. Install nvidia-docker 2.0 from Nvidia Docker 2.0
  3. Register nvidia runtime with the Docker engine using Nvidia Container Runtime

Docker: Build Image

docker build -t magnetloss .

Docker: Train

Deploy and train on Docker container:

docker run --rm -it --runtime=nvidia magnetloss python magnet_loss_test.py --lr 1e-4 --mnist --batch-size 64 --dml

or

./run_gpu_docker.sh magnetloss

Results

MNIST

Iterations Learned Embedding Space
0
2000
4000
6000
8000
10000
12000
14000

Other Implementations

Citing MagnetLoss-PyTorch

If you use MagnetLoss-PyTorch in a scientific publication, I would appreciate references to the source code.

Biblatex entry:

@misc{vithu2018,
  author = {Thangarasa, Vithursan},
  title = {MagnetLoss-PyTorch},
  year = {2018},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/vithursant/MagnetLoss-PyTorch}}
}

magnetloss-pytorch's People

Contributors

vithursant avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.