Tensor Equivalent for Numpy Indexing

What is pseudo (*) - equivalent in Tensorflow for this?

array[array < 50] = 0 # numpy

I assume this should be something like:

array = tf.something(array, ...) # or array2 = ...
# OR
array = array.something(...) # or array2 = ...

(*) I do not pretend to save the mutable array and its execution at the moment, since I would be a tensor.

Maybe another way to ask the question: what will be the code for applying the array of conditional tensors tf.cond () depending on tf.less () to an array of numbers?

+4
source share
1 answer

You can do

tf.select(array < 50, tf.zeros_like(array), array)

, , array array[array < 50] = 0. array TensorFlow, tf.assign, array.

+5

Source: https://habr.com/ru/post/1629943/


All Articles