TensorFlow的图像NCHW与NHWC

时间:2020-01-31 22:41:02   收藏:0   阅读:181

技术分享图片

 

 

import tensorflow as tf

x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

with tf.Session() as sess:
    a = tf.reshape(x, [2, 2, 3])
    a = sess.run(a)
    print(a)
    print("----------------------------")
    b = tf.reshape(a,[3,2,2])
    b = sess.run(b)
    print(b)
    print("-----------------------------")
    c = tf.transpose(b,[1,2,0])
    c = sess.run(c)
    print(c)

结果:
[[[ 1  2  3]
  [ 4  5  6]]

 [[ 7  8  9]
  [10 11 12]]]
----------------------------
[[[ 1  2]
  [ 3  4]]

 [[ 5  6]
  [ 7  8]]

 [[ 9 10]
  [11 12]]]
-----------------------------
[[[ 1  5  9]
  [ 2  6 10]]

 [[ 3  7 11]
  [ 4  8 12]]]

  技术分享图片

 

原文:https://www.cnblogs.com/LiuXinyu12378/p/12246779.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!