title: Invert Theano tensor element-wise
body: <p>My goal is to invert the values in a Theano tensor element-wise. For instance, I want to turn <code>[4, 5, 10]</code> into <code>[0.25, 0.2, 0.1]</code>. If there is a zero element, I want to keep it unchanged (e.g. <code>[0, 4, 5, 10]</code> should be turned into <code>[0, 0.25, 0.2, 0.1]</code>). What is the most elegant way of doing this?</p>
  
  <p>My solution was to add a very small value to all the elements:</p>
  
  <pre><code>v = t.vector()
  result = 1 / (v + 0.000001)
  </code></pre>
  
  <p>I am aware that I could use a <code>scan</code> to iterate over the elements and check individually whether they can be inverted, but I want my code to look as mathsy as possible.</p>