Giter VIP home page Giter VIP logo

pytorch_sym3eig's Introduction

Pytorch extension: Batch-wise eigencomputation for symmetric 3x3 matrices


The operator works on 32 and 64 bit floating point data types and is implemented both for CPU and GPU with custom kernels. Implementations include forward and backward steps.

The full code for our work Deep Iterative Surface Normal Estimation can be found here: https://github.com/nnaisense/deep-iterative-surface-normal-estimation.

Installation

Ensure that at least PyTorch >= 1.0.0 is installed, checkout repository and run:

python setup.py install

Running tests

python setup.py test

Requires pytest and numpy.

Usage

import torch
from torch_sym3eig import Sym3Eig

matrices = torch.rand(100, 3, 3)
# Matrices need to be symmetric
matrices = (matrices + torch.transpose(matrices, 1, 2))/2.0

eig_vals, eig_vecs = Sym3Eig.apply(matrices)

Benchmarks

Runtimes for 100k matrices on an i7-7700K @ 4.20GHz and a GTX Titan X, respectively:

CPU GPU
Forward 23.59 ms 1.93 ms
Backward 20.47 ms 1.31 ms

Running benchmarks:

python test/benchmark.py 100000

Parameters

  • x (Tensor) - Input matrices (symmetric 3x3) (number_of_matrices x 3 x 3).

Returns

  • eig_vals (Tensor) - Eigenvalues of the input matrices in no pre-defined order(number_of_matrices x 3).
  • eig_vecs (Tensor) - Corresponding eigenvectors in columns(number_of_matrices x 3 x 3).

Information

The module was initially created for and used in our Deep Iterative Surface Normal Estimation paper, which can be cited as reference:

@misc{lenssen2019,
    title={Deep Iterative Surface Normal Estimation},
    author={Jan Eric Lenssen and Christian Osendorfer and Jonathan Masci},
    year={2019},
    eprint={1904.07172},
    archivePrefix={arXiv},
}

The implementation follows the derivations from:

  • Mike B. Giles. Collected matrix derivative results for forward and reverse mode algorithmic differentiation. In Advances in Automatic Differentiation, pages 35โ€“44. Springer Berlin Heidelberg, 2008, and
  • https://en.wikipedia.org/wiki/Eigenvalue_algorithm

pytorch_sym3eig's People

Contributors

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