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

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

NHWC&NCHW简介


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

image.png

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)





相关文章
|
8月前
|
存储 缓存 数据可视化
(七)解析Streamlit的数据元素:探索st.dataframe、st.data_editor、st.column_config、st.table、st.metric和st.json的神奇之处(上)
(七)解析Streamlit的数据元素:探索st.dataframe、st.data_editor、st.column_config、st.table、st.metric和st.json的神奇之处
2195 0
|
8月前
|
存储 NoSQL UED
(七)解析Streamlit的数据元素:探索st.dataframe、st.data_editor、st.column_config、st.table、st.metric和st.json的神奇之处(中)
(七)解析Streamlit的数据元素:探索st.dataframe、st.data_editor、st.column_config、st.table、st.metric和st.json的神奇之处
548 0
|
8月前
|
存储 JSON 数据可视化
(七)解析Streamlit的数据元素:探索st.dataframe、st.data_editor、st.column_config、st.table、st.metric和st.json的神奇之处(下)
(七)解析Streamlit的数据元素:探索st.dataframe、st.data_editor、st.column_config、st.table、st.metric和st.json的神奇之处
561 0
|
SQL
format函数
format函数
103 0
|
数据可视化 PyTorch 算法框架/工具
Pychram Pytorch Tensorboard 报错 “No dashboards are active for the current data set.“ 解决方案
Pychram Pytorch Tensorboard 报错 “No dashboards are active for the current data set.“ 解决方案
Pychram Pytorch Tensorboard 报错 “No dashboards are active for the current data set.“ 解决方案
|
数据挖掘 开发者
Data-Measuring Data Similarity and Dissimilarity| 学习笔记
快速学习 Data-Measuring Data Similarity and Dissimilarity。
149 0
Data-Measuring Data Similarity and Dissimilarity| 学习笔记
|
JSON 数据格式 Python
python编程:json indent can't multiply sequence by non-int of type 'str'
python编程:json indent can't multiply sequence by non-int of type 'str'
109 0
|
测试技术
如何使用 jMeter CSV Data Set config
如何使用 jMeter CSV Data Set config
如何使用 jMeter CSV Data Set config
【转载】format的用法。
以前没太注意这个用法,到网上找一个,copy过来,方便以后的查看。   "I see stuff like {0,-8:G2} passed in as a format string. What exactly does that do?" -- Very Confused String Fo...
874 0

热门文章

最新文章