I understand from your question that you want to know how “image3dinputLayer” in MATLAB is calculating “zerocenter” for your data.
Zero-centering involves subtracting the mean value of the dataset from each input sample. This ensures that the data is centered around zero. When you specify 'Normalization','zerocenter', MATLAB automatically calculates the mean of the training data (across the entire dataset) and subtracts it during each forward pass.
Mean calculation process: If the input data has multiple frames (e.g., 3 channels for RGB images), MATLAB calculates the mean for each frame independently. For example, if you have an input with the shape [height, width, frame, channels], the mean for each frame (e.g., red, green, blue) is calculated by averaging the values across all samples.
Assume your 4D input data has the shape [64, 64, 64, 3, 100],
- where 64 x 64 x 64 is the size of each sample,
- 3 is the number of channels and
- 100 is the number of training samples.
MATLAB will calculate the mean for each of the 3 frames across all 100 samples. It will calculate the average of all values in the corresponding location (i, j, k) over all 100 samples. This is done independently for each channel.
So, for each input (i, j, k, c) in the data, the zero-centered value would be:
New_data (i,j,k,c) = input (i,j,k,c) – mean_data (i,j,k,c)
For more clarification, the following documentation link would be helpful:
You can also try this command in your MATLAB command window for specific release documentation:
web(fullfile(docroot, 'deeplearning/ref/nnet.cnn.layer.image3dinputlayer.html'))
Hope this helps you!