Code Monkey home page Code Monkey logo

lorentz-embeddings's Introduction

Lorentz Embeddings

A pytorch implementation of Learning Continuous Hierarchies in the Lorentz Model of Hyperbolic Geometry.

We are concerned with the discovery of hierarchical relationships from large-scale unstructured similarity scores. For this purpose, we study different models of hyperbolic space and find that learning embeddings in the Lorentz model is substantially more efficient than in the Poincaré-ball model. We show that the proposed approach allows us to learn high-quality embeddings of large taxonomies which yield improvements over Poincaré embeddings, especially in low dimensions. Lastly, we apply our model to discover hierarchies in two real-world datasets: we show that an embedding in hyperbolic space can reveal important aspects of a company’s organizational structure as well as reveal historical relationships between language families.

An example of a binary tree being embedded in the Lorentz space and then visualized using Poincaré space. Binary Tree Embedding

NOTE : @lambdaofgod has generously ported this work to use sparse matrices and a bunch of other nice things! Go check out the PR at theSage21#15 . We haven't merged that work since it does not have updated examples. If you have the time please go ahead and submit a PR to either their repo or this one.

Usage

Binary tree embedding and visualization.

# See this for more options
python lorentz.py --help


python lorentz.py bin_mat  # run binary tree


# plot the checkpoint's embeddings for all saved checkpoints
# in poincare space
python lorentz.py bin_mat -plot -ckpt ckpt  # plot only embeddings
python lorentz.py bin_mat -plot -ckpt ckpt -plot_graph  # plot graph also
python lorentz.py bin_mat -plot -ckpt ckpt -plot_graph  -overwrite_plots # overwrite plots
python lorentz.py bin_mat -plot -ckpt ckpt -plot_graph  -plot_size 10 # make a large plot

To embed an arbitrary graph

  1. Add a numpy matrix in the datasets.py file with a unique name (my_graph for example). This represents a directed adjacency matrix
  2. Now you can simply call python lorentz.py my_graph to embed your graph.
  3. You can use tensorboard to watch the progress with tensorboard --logdir runs.
  4. You can plot the embeddings using python lorentz.py my_graph -plot -ckpt ckpt

For anything else python lorentz.py --help

lorentz-embeddings's People

Contributors

dchatterjee172 avatar thesage21 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.