GithubHelp home page GithubHelp logo

codeaudit / deepnorms Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spitis/deepnorms

0.0 2.0 0.0 751 KB

Code for An Inductive Bias for Distances: Neural Nets that Respect the Triangle Inequality (ICLR 2020)

Jupyter Notebook 95.48% Python 4.52%

deepnorms's Introduction

An Inductive Bias for Distances: Neural Nets that Respect the Triangle Inequality

Silviu Pitis*, Harris Chan*, Kiarash Jamali, Jimmy ba

This repo contains Tensorflow v1 and Pytorch implementations of Deep Norms, Wide Norms, and Neural Metrics, from our ICLR 2020 paper, which may be found at:

Bibtex

@inproceedings{pitis2020inductive,
  title={An Inductive Bias for Distances: Neural Nets that Respect the Triangle Inequality},
  author={Pitis, Silviu and Chan, Harris and Jamali, Kiarash and Ba, Jimmy},
  booktitle={Proceedings of the Eighth International Conference on Learning Representations},
  year={2020}
}

Installing dependencies

To create a conda/virtualenv and install dependencies for our code, assuming that ${DEEPNORM_ROOT} the directory that you cloned our repository into:

conda create -n deepnorm
conda activate deepnorm
cd ${DEEPNORM_ROOT}
pip install -r requirements.txt

File Descriptions

The main implementation files are:

  • metrics_tf1.py: defines the model components in Tensorflow v1 code
  • metrics_pytorch.py: reimplementations of the model components in Pytorch (untested)
  • custom_metric_loss_ops.py: drop in replacement for Tensorflow v1's contrib.metric_loss_ops that computes pairwise distances using our models

Pytorch examples

To run Pytorch examples, use pytorch_examples.ipynb.

Additional files for graph experiments

Some additional files to reproduce some of our experiments (Please note: this is TFv1 research code, there are no guarantees that this will "just work".):

  • Make3dAndTaxi.ipynb: creates 3d and Taxi graphs in form of .edgelist
  • PrepXYDPickles.ipynb: creates the dataset (but not embeddings)
  • data.py: makes landmark embeddings given a .edgelist, and loads datasets used in experiments
  • experiment.py: runs experiment given an embedding pickle and a dataset pickle

How to run graph experiments

  1. Use Make3dAndTaxi.ipynb to make .edgelist
  2. Use PrepXYDPickles.ipynb given .edgelist
  3. Use make_lm_embeddings from data.py given .edgelist
  4. Use experiment.py to run experiment using pickes created in previous two steps

How to run 2D Norms experiment

  1. Run python experiment_2d_norm.py. This trains several architectures on different 2D norms and saves the results in ./2D_metrics folder.
  2. Launch the notebook 2D Norm Result Plotting.ipynb and run the cells to update the plots for the results.

deepnorms's People

Contributors

spitis 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.