您当前的位置: 首页 > 
  • 0浏览

    0关注

    2393博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

TF之data_format:data_format中的NHWC&NCHW简介、转换的详细攻略

一个处女座的程序猿 发布时间:2018-06-25 19:45:48 ,浏览量:0

TF之data_format:data_format中的NHWC&NCHW简介、转换的详细攻略

 

 

目录

NHWC&NCHW简介

NHWC&NCHW转换

 

 

NHWC&NCHW简介

NHWC & NCHW是两种参数呈现的表达方式。在如何表示一组彩色图片的问题上,不同的DL框架有不同的表达。

 形式适合的框架 

NHWC

channels_first

[batch, in_height, in_width, in_channels]

批量批次、高度、宽度、通道数

TensorFlow 

NCHW

channels_last

[batch, in_channels, in_height, in_width]

批量批次、通道数、高度、宽度

Theano、Caffe 

 

NHWC&NCHW转换

1、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)

 

2、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)

 

 

 

 

 

 

关注
打赏
1664196048
查看更多评论
立即登录/注册

微信扫码登录

0.0445s