title: Keras returns wrong value for sum
body: <p>I have this code to understand how Jaccard Index works and I am trying to implement it as a Keras custom metric, but the return of this function is wrong and I have no idea why (I am new to Keras btw).</p>
  
  <p>This function creates a rectangular area to test intersections:</p>
  
  <pre class="lang-py prettyprint-override"><code>def block(start, width=20, heigth=10, length=60):
      block = np.zeros((1, heigth, length))
      block[:, :, start:(start + width)] = 1
      return block.astype('uint8')
  </code></pre>
  
  <p>If I get a <code>block(10)</code> and a <code>block(20)</code> there should be two 10x20 blocks with a 10x10 area of intersection so the union must be <code>2*(10*20) - 10*10</code> which is confirmed by this Numpy line:</p>
  
  <pre class="lang-py prettyprint-override"><code>np.sum(((block(10) + block(20)) &gt; 0).astype('uint8'))
  </code></pre>
  
  <p>But when I try to use this Keras function:</p>
  
  <pre><code>def test(a, b):
      return K.sum(K.cast((a + b) &gt; 0, dtype='uint8'))
  </code></pre>
  
  <p>The result is 44 when I call it with <code>K.eval(test(block(10), block(20)))</code></p>
  
  <p>EDIT (new test):</p>
  
  <pre><code>def test(a, b):
      return K.sum(a), K.sum(b), K.sum(a) + K.sum(b)
  
  [K.eval(elem) for elem in test(block(10), block(20))]
  </code></pre>
  
  <p>This is the result: <code>[200, 200, 144]</code></p>
  
  <p>What am I doing wrong to get this result?</p>