Is there a way to figure out if an NDArray is trainable/has a gradient? #19414
-
Is there a way to figure out if an I've tried checking whether import mxnet as mx
x = mx.nd.array([1, 2])
x.attach_grad()
with mx.autograd.record():
y = x**2
z = 2 * y
z.backward()
>>> print(x.grad)
[4. 8.]
<NDArray 2 @cpu(0)>
>>> print(y.grad)
None In this example, I've tried looking through the source code, but can't figure it out. Corresponding SO post: https://stackoverflow.com/questions/64473958/is-there-a-way-to-figure-out-if-an-ndarray-is-trainable |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There isn't a direct way to access this information at the moment. It can be found in the backward operators as the req variable but it's not easy to tie this back to an NDArray. What do you need this information for? |
Beta Was this translation helpful? Give feedback.
There isn't a direct way to access this information at the moment. It can be found in the backward operators as the req variable but it's not easy to tie this back to an NDArray.
What do you need this information for?