Keras Conv3D input shape clarification: spatial dimensions vs width/height/depth

3 weeks ago 36
ARTICLE AD BOX

I'm trying to use Conv3D in Keras and the documentation is a bit confusing regarding the input shape.

The Conv3D docs say:

This layer creates a convolution kernel that is convolved with the layer input over a 3D spatial (or temporal) dimension (width, height, and depth).
Input shape:

If data_format="channels_last": 5D tensor with shape (batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)

If data_format="channels_first": 5D tensor with shape (batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)

My input has the shape (B, D, W, H, C) — that is, (batch, depth, width, height, channels).

My questions:

Does Keras care about the exact order of width, height, and depth, or is it enough that I just stick to some consistent ordering of the three spatial dimensions throughout the model?

In other words, is (B, D, W, H, C) compatible with channels_last format, or should I reorder it to (B, H, W, D, C) or (B, D, H, W, C)?

I want to make sure I’m convolving over the correct spatial dimensions and avoid subtle bugs.

Thanks in advance!

Read Entire Article