title: Tensorflow/Keras Conv2D layers with padding='SAME' behave strangely
body: <p><strong>My question:</strong></p>
  
  <p>A straightforward experiment that I conducted showed that using <code>padding='SAME'</code> in a conv2d layer in Keras/TF is different from using <code>padding='VALID'</code> with a preceding zero-padding layer.</p>
  
  <ol>
  <li>How is that possible?</li>
  <li>Does Keras/TF pads zeros symmetrically around the tensor?</li>
  </ol>
  
  <p><strong>Explanation of the experiment - just if you're interested in reading further:</strong></p>
  
  <p>I used the <code>onnx2keras</code> package to convert my Pytorch model into keras/TF.</p>
  
  <p>When <code>onnx2keras</code> encounters a convolutional layer with <code>padding &gt; 0</code> in the ONNX model, it translates it to Keras' <code>Conv2D</code> with <code>valid</code> padding (i.e., no padding!), preceded by Keras' <code>ZeroPadding2D</code> layer. This works very well and returns outputs that are identical to those produced by the Pytorch network.</p>
  
  <p>I yet thought it was strange that it didn't simply used <code>padding='SAME'</code>, as most of the references say that Keras/TF use zero padding, just like Pytorch does.</p>
  
  <p>Nevertheless, I patched <code>onnx2keras</code> and made it produce me <code>Conv2D</code> layers with <code>padding='SAME'</code> rather than the existing solution of <code>'VALID'</code> padding with a preceding zero-padding layer. This made the resulting model return different outputs than the one with the zero-padding layer, and of course different from my Pytorch model, which was identical until the patch. </p>