title: how tf.space_to_depth() works in tensorflow?
body: <p>I am a pytorch user. I have got a pretrained model in tensorflow and I would like to transfer it into pytorch. In one part of model architecture, I mean in tensorflow-defined model, there is a function <strong>tf.space_to_depth</strong> which transfers an input size of (None, 38,38,64) to (None, 19,19, 256). (<a href="https://www.tensorflow.org/api_docs/python/tf/space_to_depth" rel="noreferrer">https://www.tensorflow.org/api_docs/python/tf/space_to_depth</a>) is the doc of this function. But I could not understand what this function actually do. Could you please provide some numpy codes to illustrate it for me?</p>
  
  <p>Actually I would like to make an exact similar layer in pytorch.</p>
  
  <p>Some codes in tensorflow reveals another secret:
  Here is some codes:</p>
  
  <pre><code>import numpy as np
  import tensorflow as tf
  
  norm = tf.random_normal([1, 2, 2, 1], mean=0, stddev=1)
  trans = tf.space_to_depth(norm,2)
  
  with tf.Session() as s:
      norm = s.run(norm)
      trans = s.run(trans)
  
  
  
  print("Norm")
  print(norm.shape)
  for index,value in np.ndenumerate(norm):
      print(value)
  
  print("Trans")
  print(trans.shape)
  for index,value in np.ndenumerate(trans):
      print(value)
  </code></pre>
  
  <p>And here is the output:</p>
  
  <pre><code>Norm
  (1, 2, 2, 1)
  0.695261
  0.455764
  1.04699
  -0.237587
  Trans
  (1, 1, 1, 4)
  1.01139
  0.898777
  0.210135
  2.36742
  </code></pre>
  
  <p>As you can see above, In Addition to data reshaping, the tensor values has changed!</p>