Curvlearn, a Tensorflow based non-Euclidean deep learning framework.

Overview

English | 简体中文

Why Non-Euclidean Geometry

Considering these simple graph structures shown below. Nodes with same color has 2-hop distance whereas 1-hop distance between nodes with different color. Now how could we embed these structures in Euclidean space while keeping these distance unchanged?

Actually perfect embedding without distortion, appearing naturally in hyperbolic (negative curvature) or spherical (positive curvature) space, is infeasible in Euclidean space [1].

As shown above, due to the high capacity of modeling complex structured data, e.g. scale-free, hierarchical or cyclic, there has been an growing interest in building deep learning models under non-Euclidean geometry, e.g. link prediction [2], recommendation [3].

What's CurvLearn

In this repository, we provide a framework, named CurvLearn, for training deep learning models in non-Euclidean spaces.

The framework implements the non-Euclidean operations in Tensorflow and remains the similar interface style for developing deep learning models.

Currently, CurvLearn serves for training several recommendation models in Alibaba. We implement CurvLearn on top of our distributed (graph/deep learning) training engines including Euler and x-deeplearning. The figure below shows how the category tree is embedded in hyperbolic space by using CurvLearn.

Why CurvLearn

CurvLearn has the following major features.

  1. Easy-to-Use. Converting a Tensorflow model from Euclidean space to non-Euclidean spaces with CurvLearn is graceful and undemanding, due to the manifold operations are decoupled from model architecture and similar to vanilla Tensorflow operations. For researchers, CurvLearn also reserves lucid interfaces for developing novel manifolds and optimizers.
  2. Comprehensive methods. CurvLearn is the first Tensorflow based non-Euclidean deep learning framework and supports several typical non-Euclidean spaces, e.g. constant curvature and mixed-curvature manifolds, together with necessary manifold operations and optimizers.
  3. Verified by tremendous industrial traffic. CurvLearn is serving on Alibaba's sponsored search platform with billions of online traffic in several key scenarios e.g. matching and cate prediction. Compared to Euclidean models, CurvLearn can bring more revenue and the RPM (revenue per mille) increases more than 1%.

Now we are working on exploring more non-Euclidean methods and integrating operations with Tensorflow. PR is welcomed!

CurvLearn Architecture

Manifolds

We implemented several types of constant curvature manifolds and the mixed-curvature manifold.

  • curvlearn.manifolds.Euclidean - Euclidean space with zero curvature.
  • curvlearn.manifolds.Stereographic - Constant curvature stereographic projection model. The curvature can be positive, negative or zero.
  • curvlearn.manifolds.PoincareBall - The stereographic projection of the Lorentz model with negative curvature.
  • curvlearn.manifolds.ProjectedSphere - The stereographic projection of the sphere model with positive curvature.
  • curvlearn.manifolds.Product - Mixed-curvature space consists of multiple manifolds with different curvatures.

Operations

To build a non-Euclidean deep neural network, we implemented several basic neural network operations. Complex operations can be decomposed into basic operations explicitly or realized in tangent space implicitly.

  • variable(t, c) - Defines a riemannian variable from manifold or tangent space at origin according to its name.
  • to_manifold(t, c, base) - Converts a tensor t in the tangent space of base point to the manifold.
  • to_tangent(t, c, base) - Converts a tensor t in the manifold to the tangent space of base point.
  • weight_sum(tensor_list, a, c) - Computes the sum of tensor list tensor_list with weight list a.
  • mean(t, c, axis) - Computes the average of elements along axis dimension of a tensor t.
  • sum(t, c, axis) - Computes the sum of elements along axis dimension of a tensor t.
  • concat(tensor_list, c, axis) - Concatenates tensor list tensor_list along axis dimension.
  • matmul(t, m, c) - Multiplies tensor t by euclidean matrix m.
  • add(x, y, c) - Adds tensor x and tensor y.
  • add_bias(t, b, c) - Adds a euclidean bias vector b to tensor t.
  • activation(t, c_in, c_out, act) - Computes the value of activation function act for the input tensor t.
  • linear(t, in_dim, out_dim, c_in, c_out, act, scope) - Computes the linear transformation for the input tensor t.
  • distance(src, tar, c) - Computes the squared geodesic/distance between src and tar.

Optimizers

We also implemented several typical riemannian optimizers. Please refer to [4] for more details.

  • curvlearn.optimizers.rsgd - Riemannian stochastic gradient optimizer.
  • curvlearn.optimizers.radagrad - Riemannian Adagrad optimizer.
  • curvlearn.optimizers.radam - Riemannian Adam optimizer.

How to use CurvLearn

To get started with CurvLearn quickly, we provide a simple binary classification model as a quick start and three representative examples for the application demo. Note that the non-Euclidean model is sensitive to the hyper-parameters such as learning rate, loss functions, optimizers, and initializers. It is necessary to tune those hyper-parameters when transferring to other datasets.

Installation

CurvLearn requires tensorflow~=1.15, compatible with both python 2/3.

The preferred way for installing is via pip.

pip install curvlearn

Quick Start

Here we show how to build binary classification model using CurvLearn. Model includes Stereographic manifold, linear operations , radam optimizer, etc.

Instructions and implement details are shown in Quick Start.

HGCN on Link Prediction [2]

HGCN (Hyperbolic Graph Convolutional Neural Network) is the first inductive hyperbolic GCN that leverages both the expressiveness of GCNs and hyperbolic geometry to learn inductive node representations for hierarchical and scale-free graphs. Run the command to check the accuracy on the OpenFlight airport dataset. Running environment and performance are listed in hgcn.

python examples/hgcn/train.py

HyperML on Recommendation Ranking [3]

HyperML (Hyperbolic Metric Learning) applies hyperbolic geometry to recommender systems through metric learning approach and achieves state-of-the-art performance on multiple benchmark datasets. Run the command to check the accuracy on the Amazon Kindle-Store dataset. Running environment and performance are listed in hyperml.

python examples/hyperml/train.py

Hyper Tree Pre-train Model

In the real-world, data is often organized in tree-like structure or can be represented hierarchically. It has been proven that hyperbolic deep neural networks have significant advantages over tree-data representation than Euclidean models. In this case, we present a hyperbolic graph pre-train model for category tree in Taobao. The further details including dataset description, model architecture and visualization of results can be found in CateTreePretrain.

python examples/tree_pretrain/run_model.py

References

[1] Bachmann, Gregor, Gary Bécigneul, and Octavian Ganea. "Constant curvature graph convolutional networks." International Conference on Machine Learning. PMLR, 2020.

[2] Chami, Ines, et al. "Hyperbolic graph convolutional neural networks." Advances in neural information processing systems 32 (2019): 4868-4879.

[3] Vinh Tran, Lucas, et al. "Hyperml: A boosting metric learning approach in hyperbolic space for recommender systems." Proceedings of the 13th International Conference on Web Search and Data Mining. 2020.

[4] Bécigneul, Gary, and Octavian-Eugen Ganea. "Riemannian adaptive optimization methods." arXiv preprint arXiv:1810.00760 (2018).

License

This project is licensed under the Apache License, Version 2.0, unless otherwise explicitly stated.

Owner
Alibaba
Alibaba Open Source
Alibaba
Functional deep learning

Pipeline abstractions for deep learning. Full documentation here: https://lf1-io.github.io/padl/ PADL: is a pipeline builder for PyTorch. may be used

LF1 101 Nov 09, 2022
a simple, efficient, and intuitive text editor

Oxygen beta a simple, efficient, and intuitive text editor Overview oxygen is a simple, efficient, and intuitive text editor designed as more featured

Aarush Gupta 1 Feb 23, 2022
Repository for tackling Kaggle Ultrasound Nerve Segmentation challenge using Torchnet.

Ultrasound Nerve Segmentation Challenge using Torchnet This repository acts as a starting point for someone who wants to start with the kaggle ultraso

Qure.ai 46 Jul 18, 2022
A parametric soroban written with CADQuery.

A parametric soroban written in CADQuery The purpose of this project is to demonstrate how "code CAD" can be intuitive to learn. See soroban.py for a

Lee 4 Aug 13, 2022
Python Assignments for the Deep Learning lectures by Andrew NG on coursera with complete submission for grading capability.

Python Assignments for the Deep Learning lectures by Andrew NG on coursera with complete submission for grading capability.

Utkarsh Agiwal 1 Feb 03, 2022
GCC: Graph Contrastive Coding for Graph Neural Network Pre-Training @ KDD 2020

GCC: Graph Contrastive Coding for Graph Neural Network Pre-Training Original implementation for paper GCC: Graph Contrastive Coding for Graph Neural N

THUDM 274 Dec 27, 2022
2020 CCF大数据与计算智能大赛-非结构化商业文本信息中隐私信息识别-第7名方案

2020CCF-NER 2020 CCF大数据与计算智能大赛-非结构化商业文本信息中隐私信息识别-第7名方案 bert base + flat + crf + fgm + swa + pu learning策略 + clue数据集 = test1单模0.906 词向量

67 Oct 19, 2022
Stochastic Extragradient: General Analysis and Improved Rates

Stochastic Extragradient: General Analysis and Improved Rates This repository is the official implementation of the paper "Stochastic Extragradient: G

Hugo Berard 4 Nov 11, 2022
Building Ellee — A GPT-3 and Computer Vision Powered Talking Robotic Teddy Bear With Human Level Conversation Intelligence

Using an object detection and facial recognition system built on MobileNetSSDV2 and Dlib and running on an NVIDIA Jetson Nano, a GPT-3 model, Google Speech Recognition, Amazon Polly and servo motors,

24 Oct 26, 2022
ZSL-KG is a general-purpose zero-shot learning framework with a novel transformer graph convolutional network (TrGCN) to learn class representation from common sense knowledge graphs.

ZSL-KG is a general-purpose zero-shot learning framework with a novel transformer graph convolutional network (TrGCN) to learn class representa

Bats Research 94 Nov 21, 2022
TeachMyAgent is a testbed platform for Automatic Curriculum Learning methods in Deep RL.

TeachMyAgent: a Benchmark for Automatic Curriculum Learning in Deep RL Paper Website Documentation TeachMyAgent is a testbed platform for Automatic Cu

Flowers Team 51 Dec 25, 2022
ANEA: Distant Supervision for Low-Resource Named Entity Recognition

ANEA: Distant Supervision for Low-Resource Named Entity Recognition ANEA is a tool to automatically annotate named entities in unlabeled text based on

Saarland University Spoken Language Systems Group 15 Mar 30, 2022
Official code for our ICCV paper: "From Continuity to Editability: Inverting GANs with Consecutive Images"

GANInversion_with_ConsecutiveImgs Official code for our ICCV paper: "From Continuity to Editability: Inverting GANs with Consecutive Images" https://a

QingyangXu 38 Dec 07, 2022
Video Swin Transformer - PyTorch

Video-Swin-Transformer-Pytorch This repo is a simple usage of the official implementation "Video Swin Transformer". Introduction Video Swin Transforme

Haofan Wang 116 Dec 20, 2022
NeoDTI: Neural integration of neighbor information from a heterogeneous network for discovering new drug-target interactions

NeoDTI NeoDTI: Neural integration of neighbor information from a heterogeneous network for discovering new drug-target interactions (Bioinformatics).

62 Nov 26, 2022
🥇 LG-AI-Challenge 2022 1위 솔루션 입니다.

LG-AI-Challenge-for-Plant-Classification Dacon에서 진행된 농업 환경 변화에 따른 작물 병해 진단 AI 경진대회 에 대한 코드입니다. (colab directory에 코드가 잘 정리 되어있습니다.) Requirements python

siwooyong 10 Jun 30, 2022
Code for paper PairRE: Knowledge Graph Embeddings via Paired Relation Vectors.

PairRE Code for paper PairRE: Knowledge Graph Embeddings via Paired Relation Vectors. This implementation of PairRE for Open Graph Benchmak datasets (

Alipay 65 Dec 19, 2022
PyTorch implementation of SQN based on CloserLook3D's encoder

SQN_pytorch This repo is an implementation of Semantic Query Network (SQN) using CloserLook3D's encoder in Pytorch. For TensorFlow implementation, che

PointCloudYC 1 Oct 21, 2021
Model Quantization Benchmark

Introduction MQBench is an open-source model quantization toolkit based on PyTorch fx. The envision of MQBench is to provide: SOTA Algorithms. With MQ

500 Jan 06, 2023
MILK: Machine Learning Toolkit

MILK: MACHINE LEARNING TOOLKIT Machine Learning in Python Milk is a machine learning toolkit in Python. Its focus is on supervised classification with

Luis Pedro Coelho 610 Dec 14, 2022