In [1]:
import tensorflow as tf

a = tf.lin_space(1.0, 50, 50)
a1 = tf.reshape(a, shape=[5, -1])
b = tf.lin_space(101.0, 150, 50)
b1 = tf.reshape(b, shape=[5, -1])
c = tf.lin_space(201.0, 250, 50)
c1 = tf.reshape(c, shape=[5, -1])

d = tf.stack([a1,b1,c1])
print d


Tensor("stack:0", shape=(3, 5, 10), dtype=float32)

In [4]:
isp = d.get_shape().as_list()
e = tf.reshape(d, shape=[isp[1], -1, 1, isp[2], 1])
print e


Tensor("Reshape_5:0", shape=(5, 3, 1, 10, 1), dtype=float32)

In [5]:
f = tf.stack(tf.unstack(d, axis=1))
isp = f.get_shape().as_list()
f = tf.reshape(f, shape=[isp[0], isp[1], 1, isp[2], 1])
print f
# tf.reshape(model_input, shape=[isp[1], -1, 1, isp[2], 1])


Tensor("Reshape_6:0", shape=(5, 3, 1, 10, 1), dtype=float32)

In [11]:
bottoms = tf.unstack(f, axis=0)
print bottoms

sess = tf.Session()
print sess.run(d)


[<tf.Tensor 'unstack_5:0' shape=(3, 1, 10, 1) dtype=float32>, <tf.Tensor 'unstack_5:1' shape=(3, 1, 10, 1) dtype=float32>, <tf.Tensor 'unstack_5:2' shape=(3, 1, 10, 1) dtype=float32>, <tf.Tensor 'unstack_5:3' shape=(3, 1, 10, 1) dtype=float32>, <tf.Tensor 'unstack_5:4' shape=(3, 1, 10, 1) dtype=float32>]
[[[   1.    2.    3.    4.    5.    6.    7.    8.    9.   10.]
  [  11.   12.   13.   14.   15.   16.   17.   18.   19.   20.]
  [  21.   22.   23.   24.   25.   26.   27.   28.   29.   30.]
  [  31.   32.   33.   34.   35.   36.   37.   38.   39.   40.]
  [  41.   42.   43.   44.   45.   46.   47.   48.   49.   50.]]

 [[ 101.  102.  103.  104.  105.  106.  107.  108.  109.  110.]
  [ 111.  112.  113.  114.  115.  116.  117.  118.  119.  120.]
  [ 121.  122.  123.  124.  125.  126.  127.  128.  129.  130.]
  [ 131.  132.  133.  134.  135.  136.  137.  138.  139.  140.]
  [ 141.  142.  143.  144.  145.  146.  147.  148.  149.  150.]]

 [[ 201.  202.  203.  204.  205.  206.  207.  208.  209.  210.]
  [ 211.  212.  213.  214.  215.  216.  217.  218.  219.  220.]
  [ 221.  222.  223.  224.  225.  226.  227.  228.  229.  230.]
  [ 231.  232.  233.  234.  235.  236.  237.  238.  239.  240.]
  [ 241.  242.  243.  244.  245.  246.  247.  248.  249.  250.]]]

In [12]:
print sess.run(e)


[[[[[   1.]
    [   2.]
    [   3.]
    [   4.]
    [   5.]
    [   6.]
    [   7.]
    [   8.]
    [   9.]
    [  10.]]]


  [[[  11.]
    [  12.]
    [  13.]
    [  14.]
    [  15.]
    [  16.]
    [  17.]
    [  18.]
    [  19.]
    [  20.]]]


  [[[  21.]
    [  22.]
    [  23.]
    [  24.]
    [  25.]
    [  26.]
    [  27.]
    [  28.]
    [  29.]
    [  30.]]]]



 [[[[  31.]
    [  32.]
    [  33.]
    [  34.]
    [  35.]
    [  36.]
    [  37.]
    [  38.]
    [  39.]
    [  40.]]]


  [[[  41.]
    [  42.]
    [  43.]
    [  44.]
    [  45.]
    [  46.]
    [  47.]
    [  48.]
    [  49.]
    [  50.]]]


  [[[ 101.]
    [ 102.]
    [ 103.]
    [ 104.]
    [ 105.]
    [ 106.]
    [ 107.]
    [ 108.]
    [ 109.]
    [ 110.]]]]



 [[[[ 111.]
    [ 112.]
    [ 113.]
    [ 114.]
    [ 115.]
    [ 116.]
    [ 117.]
    [ 118.]
    [ 119.]
    [ 120.]]]


  [[[ 121.]
    [ 122.]
    [ 123.]
    [ 124.]
    [ 125.]
    [ 126.]
    [ 127.]
    [ 128.]
    [ 129.]
    [ 130.]]]


  [[[ 131.]
    [ 132.]
    [ 133.]
    [ 134.]
    [ 135.]
    [ 136.]
    [ 137.]
    [ 138.]
    [ 139.]
    [ 140.]]]]



 [[[[ 141.]
    [ 142.]
    [ 143.]
    [ 144.]
    [ 145.]
    [ 146.]
    [ 147.]
    [ 148.]
    [ 149.]
    [ 150.]]]


  [[[ 201.]
    [ 202.]
    [ 203.]
    [ 204.]
    [ 205.]
    [ 206.]
    [ 207.]
    [ 208.]
    [ 209.]
    [ 210.]]]


  [[[ 211.]
    [ 212.]
    [ 213.]
    [ 214.]
    [ 215.]
    [ 216.]
    [ 217.]
    [ 218.]
    [ 219.]
    [ 220.]]]]



 [[[[ 221.]
    [ 222.]
    [ 223.]
    [ 224.]
    [ 225.]
    [ 226.]
    [ 227.]
    [ 228.]
    [ 229.]
    [ 230.]]]


  [[[ 231.]
    [ 232.]
    [ 233.]
    [ 234.]
    [ 235.]
    [ 236.]
    [ 237.]
    [ 238.]
    [ 239.]
    [ 240.]]]


  [[[ 241.]
    [ 242.]
    [ 243.]
    [ 244.]
    [ 245.]
    [ 246.]
    [ 247.]
    [ 248.]
    [ 249.]
    [ 250.]]]]]

In [13]:
print sess.run(f)


[[[[[   1.]
    [   2.]
    [   3.]
    [   4.]
    [   5.]
    [   6.]
    [   7.]
    [   8.]
    [   9.]
    [  10.]]]


  [[[ 101.]
    [ 102.]
    [ 103.]
    [ 104.]
    [ 105.]
    [ 106.]
    [ 107.]
    [ 108.]
    [ 109.]
    [ 110.]]]


  [[[ 201.]
    [ 202.]
    [ 203.]
    [ 204.]
    [ 205.]
    [ 206.]
    [ 207.]
    [ 208.]
    [ 209.]
    [ 210.]]]]



 [[[[  11.]
    [  12.]
    [  13.]
    [  14.]
    [  15.]
    [  16.]
    [  17.]
    [  18.]
    [  19.]
    [  20.]]]


  [[[ 111.]
    [ 112.]
    [ 113.]
    [ 114.]
    [ 115.]
    [ 116.]
    [ 117.]
    [ 118.]
    [ 119.]
    [ 120.]]]


  [[[ 211.]
    [ 212.]
    [ 213.]
    [ 214.]
    [ 215.]
    [ 216.]
    [ 217.]
    [ 218.]
    [ 219.]
    [ 220.]]]]



 [[[[  21.]
    [  22.]
    [  23.]
    [  24.]
    [  25.]
    [  26.]
    [  27.]
    [  28.]
    [  29.]
    [  30.]]]


  [[[ 121.]
    [ 122.]
    [ 123.]
    [ 124.]
    [ 125.]
    [ 126.]
    [ 127.]
    [ 128.]
    [ 129.]
    [ 130.]]]


  [[[ 221.]
    [ 222.]
    [ 223.]
    [ 224.]
    [ 225.]
    [ 226.]
    [ 227.]
    [ 228.]
    [ 229.]
    [ 230.]]]]



 [[[[  31.]
    [  32.]
    [  33.]
    [  34.]
    [  35.]
    [  36.]
    [  37.]
    [  38.]
    [  39.]
    [  40.]]]


  [[[ 131.]
    [ 132.]
    [ 133.]
    [ 134.]
    [ 135.]
    [ 136.]
    [ 137.]
    [ 138.]
    [ 139.]
    [ 140.]]]


  [[[ 231.]
    [ 232.]
    [ 233.]
    [ 234.]
    [ 235.]
    [ 236.]
    [ 237.]
    [ 238.]
    [ 239.]
    [ 240.]]]]



 [[[[  41.]
    [  42.]
    [  43.]
    [  44.]
    [  45.]
    [  46.]
    [  47.]
    [  48.]
    [  49.]
    [  50.]]]


  [[[ 141.]
    [ 142.]
    [ 143.]
    [ 144.]
    [ 145.]
    [ 146.]
    [ 147.]
    [ 148.]
    [ 149.]
    [ 150.]]]


  [[[ 241.]
    [ 242.]
    [ 243.]
    [ 244.]
    [ 245.]
    [ 246.]
    [ 247.]
    [ 248.]
    [ 249.]
    [ 250.]]]]]

In [ ]: