Search code examples
pythontensorflowkerasconv-neural-networkdata-processing

Keras Training a CNN - Should I Convert Heatmap Data As Image or 2D Matrix


I am interested in training a Keras CNN and I have some data in the form of 2D matrices (e.g. width x height). I normally represent, or visualize the data like a heatmap, with a colorbar.

However, in training the CNN and formatting the data input, I'm wondering if I should keep this matrix as a 2D matrix, or convert it into an RGB image that is essentially a 3D matrix?

What is the best practice and some considerations people should take into account?


Solution

  • In fact - you need to reshape a single data point to have a 3D shape - as keras expects your dataset to have shape (number examples, width, height, channels). If you don't wont to make your image RGB - you can simply leave it with only one channel (and interpret it as greyscale channel).