How can I compute element-wise conditionals on batches in TensorFlow? : <p>I basically have a batch of neuron activations of a layer in a tensor <code>A</code> of shape <code>[batch_size, layer_size]</code>. Let <code>B = tf.square(A)</code>. Now I want to compute the following conditional on each element in each vector in this batch: <code>if abs(e) &lt; 1: e ← 0 else e ← B(e)</code> where <code>e</code> is the element in <code>B</code> that is at the same position as <code>e</code>. Can I somehow vectorize the entire operation with a single <code>tf.cond</code> operation?</p>
