Replies: 1 comment
-
|
fwiw To actually test import mlx.core as mx
a = mx.array([1.0, 2.0, 3.0])
def f(x):
b = mx.where(x == 3, mx.stop_gradient(x), x)
return mx.sum(b)
grad_f = mx.grad(f)
print(grad_f(a)) # array([1, 1, 0], dtype=float32)That gives the (Side note: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to gradients off for a subset of a tensor. Take the example
In this, I'm trying to turn off gradients for the 3rd element of
a. When I evaluate this, I get the resultI would have expected this to produce
Can you turn off gradients for part of a tensor?
Beta Was this translation helpful? Give feedback.
All reactions