tensorflow: (data_format) NHWC、NCHW 区别与转换

https://blog.csdn.net/jningwei/article/details/78156011

区别

NHWC

[batch, in_height, in_width, in_channels]

NCHW

[batch, in_channels, in_height, in_width]

NHWC –> NCHW:
import tensorflow as tf

x = tf.reshape(tf.range(24), [1, 3, 4, 2])
out = tf.transpose(x, [0, 3, 1, 2])

print x.shape
print out.shape

(1, 3, 4, 2)
(1, 2, 3, 4)

NCHW –> NHWC:
import tensorflow as tf

x = tf.reshape(tf.range(24), [1, 2, 3, 4])
out = tf.transpose(x, [0, 2, 3, 1])

print x.shape
print out.shape

(1, 2, 3, 4)
(1, 3, 4, 2)
 

猜你喜欢

转载自blog.csdn.net/qq_30638831/article/details/83240590