Skip to content

IntelligentControlSystems/pytorch_sqrtm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Matrix square root for PyTorch

A PyTorch function to compute the square root of a matrix with gradient support. The input matrix is assumed to be positive definite as matrix square root is not differentiable for matrices with zero eigenvalues.

Dependency

Example

import torch
from sqrtm import sqrtm

k = torch.randn(20, 10)
# Create a (hopefully) positive definite matrix
pd_mat = (k.t().matmul(k)).requires_grad_()
sqrt_mat = sqrtm(pd_mat)
sqrt_mat.sum().backward()

About

Matrix square root with gradient support for PyTorch

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages