Np.where equivalent function


I am looking for equivalent function for numpy.where(condition[, x, y]).
What I am hoping is to have a function for elementwise condition for each element on x & y depends on the boolean matrix “condition”.

But I can’t find it in current pytorch function. Is there any possibility to be included in the future ?


@norm_inf You’re trying to implement SELU :slight_smile:


I am trying to implement different elementwise penalty. Currently, I am using hack like this

Variable(condition.float()) * x + Variable((condition != 1).float()) * y

I just read about SELU things after your post, You can try using that tricks for where substitute.

But I think native Torch implementation must be faster & better than this hack.