Tensorflow Equivalent For Numpy Indexed Assignment
What is the pseudo(*)-equivalent in Tensorflow for this? array[array < 50] = 0 # numpy I guess it should be something like: array = tf.something(array, ...) # or array2 = ... #
Solution 1:
You can do
tf.select(array < 50, tf.zeros_like(array), array)
which will return an expression equivalent to what array
will contain after array[array < 50] = 0
. If array
was a TensorFlow variable, you can use tf.assign
to assign the above expression to array
.
Post a Comment for "Tensorflow Equivalent For Numpy Indexed Assignment"