Replies: 3 comments 2 replies
-
Hello, I just discovered you package and started playing arround. I found out that the followinf input doesn't work : x = mg.tensor([3,2]) whereas the following works x = mg.tensor([3.0,2.0]) that may have something to do with arrays of integers vs arrays of floats e.g this one doesn't work either x = mg.tensor([int(3.0),int(2.0)]) Cheers, |
Beta Was this translation helpful? Give feedback.
-
Hi Paul, thanks for checking out mygrad! What is going on here is that integer-dtype tensors are always treated as constants -- mygrad will never compute gradients for them In [4]: int_tensor = mg.tensor([3,2])
In [5]: int_tensor.constant
Out[5]: True
In [6]: int_tensor.backward()
In [7]: int_tensor.grad is None
Out[7]: True
In [8]: float_tensor = mg.tensor([3.0, 2.0])
In [9]: float_tensor.constant
Out[9]: False
In [10]: float_tensor.backward()
In [11]: float_tensor.grad
Out[11]: array([1., 1.]) This behavior is intended, as it doesn't make sense for integer-valued tensors to be infinitesimally varied. |
Beta Was this translation helpful? Give feedback.
-
Hi Ryan, |
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions