-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Equivalent of np.diag
?
#21
Comments
Not yet, but that's easy to add (PyTorch, TensorFlow, and JAX all seem to support it). Do you want to make a PR? |
Thanks for the answer, I can try to make a PR but I never used JAX. Side question: Is there a way to extend |
In principle, extending packages with other packages is possible, but when I did that for the development version of Foolbox Native, it was quite a pain (requires certain pip versions, not everything works, etc.). |
So I started to write a PR for this but I'm kind of confused with your test sets... Currently I have something like this: @compare_all
def test_diag_1(dummy: Tensor) -> Tensor:
t = ep.arange(dummy, 4).float32()
return ep.diag(t)
@compare_all
def test_diag_2(dummy: Tensor) -> Tensor:
t = ep.arange(dummy, 4).float32()
return ep.diag(t, k=2)
@compare_all
def test_diag_3(dummy: Tensor) -> Tensor:
t = ep.arange(dummy, 9).float32().reshape((3, 3))
return ep.diag(t)
@compare_all
def test_diag_4(dummy: Tensor) -> Tensor:
t = ep.arange(dummy, 9).float32().reshape((3, 3))
return ep.diag(t, k=2) But...
|
|
Is there an equivalent of
np.diag
ineagerpy
? If not, what would be the proper way to create a diagonal matrix from a vector?The text was updated successfully, but these errors were encountered: