Skip to content

pytorch library for stable inverse and log-determinant of exp(A) in log-domain

License

Notifications You must be signed in to change notification settings

ltl-uva/logdecomp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tests workflow

logdecomp: stable inverse and logdet in log domain.

Library for computing inv(A) (matrix inverse) and log(abs(det(A))) (signed log-determinant) and their gradients, for matrices X of the form a_ii = s_ij * exp(x_ij).

By Vlad Niculae @vene // licensed under BSD 2-clause.

Usage example

In [1]: import torch

In [2]: import logdecomp

In [3]: X = torch.randn(3, 3)

In [4]: logdecomp.logdetexp(X)
Out[4]: tensor(1.0835)

In [5]: X.exp().slogdet().logabsdet
Out[5]: tensor(1.0835)

Installation

pip install logdecomp

Building from source

Make sure you have Eigen installed. If it's in a non-standard directory, set EIGEN_DIR.

pip install .

Acknowledgements

Powered by Eigen FullPivLU decomposition with a custom log-domain datatype originally by Chris Dyer (gist) with some modifications by André Martins and myself.