TF之data_format:data_format中的NHWCNCHW简介、转换的详细攻略
生活随笔
收集整理的這篇文章主要介紹了
TF之data_format:data_format中的NHWCNCHW简介、转换的详细攻略
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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 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)?
?
?
?
?
?
總結
以上是生活随笔為你收集整理的TF之data_format:data_format中的NHWCNCHW简介、转换的详细攻略的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TF之LSTM:基于Tensorflow
- 下一篇: 成功解决absl.flags._exce