Skip to content

Matrix square root with gradient support for PyTorch

License

Notifications You must be signed in to change notification settings

steveli/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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages