Theano switch row-wise efficiently

Viewed 133

I have the following code

output = T.switch(cond, a, b)

where cond is a (N,1) bool Tensor, while a and b are (N, M) numeric Tensors with M being quite large. The condition operates on a row-wise manner.

I can easily make the switch work by running T.repeat() on cond, but this is quite slow. Is there a way I can efficiently make the bools in cond decide whether a or b should be returned?

1 Answers
Related