import torch
x = torch.rand(10, 5) * 120
min_wh = 60
max_wh = 9000
b = ((x[…, 2:4] < min_wh) | (x[…, 2:4] > max_wh)).any(1)
x[b, 4] = 0
How to implement the above code with tensoflow?
import torch
x = torch.rand(10, 5) * 120
min_wh = 60
max_wh = 9000
b = ((x[…, 2:4] < min_wh) | (x[…, 2:4] > max_wh)).any(1)
x[b, 4] = 0
How to implement the above code with tensoflow?
You can use the below functions
|
→ tf.math.logical_or (tf.math.logical_or | TensorFlow v2.16.1).any
→ tf.math.reduce_any (tf.math.reduce_any | TensorFlow v2.16.1)