TF之data_format:data_format中的NHWCNCHW简介、转换的详细攻略
生活随笔
收集整理的這篇文章主要介紹了
TF之data_format:data_format中的NHWCNCHW简介、转换的详细攻略
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
TF之data_format:data_format中的NHWC&NCHW簡介、轉(zhuǎn)換的詳細(xì)攻略
?
?
目錄
NHWC&NCHW簡介
NHWC&NCHW轉(zhuǎn)換
?
?
NHWC&NCHW簡介
NHWC & NCHW是兩種參數(shù)呈現(xiàn)的表達(dá)方式。在如何表示一組彩色圖片的問題上,不同的DL框架有不同的表達(dá)。
| ? | 形式 | 適合的框架 | ? |
| NHWC channels_first | [batch, in_height, in_width, in_channels] 批量批次、高度、寬度、通道數(shù) | TensorFlow | ? |
| NCHW channels_last | [batch, in_channels, in_height, in_width] 批量批次、通道數(shù)、高度、寬度 | Theano、Caffe | ? |
?
NHWC&NCHW轉(zhuǎn)換
1、NHWC → ?NCHW
import tensorflow as tfx = 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 tfx = 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)?
?
?
?
?
?
總結(jié)
以上是生活随笔為你收集整理的TF之data_format:data_format中的NHWCNCHW简介、转换的详细攻略的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TF之LSTM:基于Tensorflow
- 下一篇: 成功解决absl.flags._exce