NCHW vs NHWC in Machine Learning

As I've been introducing myself to the various deep learning frameworks, I've noticed a difference in the default placement of channels for images. Is there a substantial difference between NCHW vs NHCW layout? Why would I choose one over the other?

Topic convolutional-neural-network computer-vision data-formats

Category Data Science


The only difference is when you need to carry out certain operations across the channel axis such as BatchNormalisation. If you look at https://keras.io/layers/normalization/, one of the parameters for batch normalisation is as such:

axis: Integer, the axis that should be normalized (typically the features axis). For instance, after a Conv2D layer with data_format="channels_first", set axis=1 in BatchNormalization

You need to provide the axis as the model needs to know to carry out normalisation across which axis. Other than that, it doesn't make a difference in training.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.