TensorFlow中Conv3D的(batch, depth, height, width, channel)输入格式正确性问询
TensorFlow Conv3D 输入格式确认
首先你的理解完全正确,这个维度顺序是符合要求的。
TensorFlow的Conv3D层默认使用data_format="channels_last"配置,该配置下要求的输入张量顺序就是**(batch, depth, height, width, channel)**,和你当前构造的输入维度(170, 60, 320, 120, 3)完全匹配:
- 170:总样本量,训练时按批次拆分后,batch维度对应每批输入的样本数
- 60:时间维度深度,对应每组的60帧
- 320:帧的高度
- 120:帧的宽度
- 3:RGB颜色通道数
你可以通过以下简单代码做验证,运行无报错即可确认维度正确:
import tensorflow as tf from tensorflow.keras import layers # 构造和你维度一致的测试输入 test_input = tf.random.normal((170, 60, 320, 120, 3)) conv3d = layers.Conv3D(filters=8, kernel_size=3, padding="same") output = conv3d(test_input) print(f"输出张量维度:{output.shape}")
注:仅当你手动将
Conv3D的data_format参数修改为channels_first时,才需要调整维度顺序为(batch, channel, depth, height, width),默认配置下不需要做任何调整。
内容的提问来源于stack exchange,提问作者utsav bhavsar
相关产品推荐
相关产品推荐

