码迷,mamicode.com
首页 > 其他好文 > 详细

TensorFlow的图像NCHW与NHWC

时间:2020-01-31 22:33:29      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:flow   图片   div   import   bsp   session   shape   src   res   

技术图片

 

 

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]]]

  技术图片

 

TensorFlow的图像NCHW与NHWC

标签:flow   图片   div   import   bsp   session   shape   src   res   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!