Skip to content

Instantly share code, notes, and snippets.

@zou3519

zou3519/cond.py Secret

Created June 28, 2021 21:45
Show Gist options
  • Save zou3519/2c6a820bc3ef0b3a9c3107d2c26fb064 to your computer and use it in GitHub Desktop.
Save zou3519/2c6a820bc3ef0b3a9c3107d2c26fb064 to your computer and use it in GitHub Desktop.
import torch
import functorch
from functorch import vmap, grad
def foo(input, p):
result = torch.linalg.cond(input, p)
return result.sum()
input = torch.randn(5, 5)
p = 1
grad(foo)(input, p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment