CNN DataLoader::AddVariablesArray() for images with multi channels, order of input array

Hi everyone,

I am trying to use the CNN in TMVA to analys pixelized electron track images.
The images are 3D voxels of the track, with high resolution in XY and coarse resolution in Z. So I am treating the Z direction as the color channels in CNN. The images are 16x16x3 pixels in x,y and z.

The example https://root.cern/doc/master/TMVA__CNN__Classification_8C.html mentioned the possiblity to have multi-channel images as input with the AddVariablesArray() methode, and the inputLayout is
TString inputLayoutString("InputLayout=1|16|16");
For a 3 channel image, I modify the layout to 3|16|16 , but how should I order the pixels in the array? Should it be vector<int> var[768] with index i_z*256 + i_y*16 +i_x or i_y*48 + i_x*3 +i_z ?

Also I didn’t find the corresponding configuration for the layer layouts. Can I keep the same batch layout as in the tutorial example?

Thank you very much!
Best regards
Xinran

I think @moneta will be able to help you

Hello,

The order in the array should be first the x,y pixel then the color channels,
i_z*256 + i_y*16 +i_x in your case.

So following the tutorial you define:
TString inputLayoutString("InputLayout=3|16|16");
and then a layout string defining the convolutional layers and the following dense layers as in the tutorial.
The batch layout staring should not be needed and you can just pass the batch size when you define the trainingString (see tutorial).
If you have further questions, please let me know

Best

Lorenzo