How to perform this zero center

4 次查看(过去 30 天)
Lin
Lin 2021-1-26
编辑: Purvaja 2025-2-18
I am using the 3D CNN to classify the objects. In input layer matlab itself implements the training data to zero-center by default.
I am wondering how it is performing this zero centering? my data dimension consist from row, column, frame, channel (4D).
inputlayer = image3dInputLayer(inputSize,Name,Value)
'Normalization' Data transformation 'zerocenter' (default) | 'none'
Data transformation to apply every time data is forward-propagated through the input layer,
specified as the comma-separated pair consisting of 'Normalization' and one of the following.
'zerocenter' The software subtracts its mean from the training set.
'none' No transformation.
Example: 'Normalization','none'
Data Types: char

回答(1 个)

Purvaja
Purvaja 2025-2-18
编辑:Purvaja 2025-2-18
Hi @Lin,
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!

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by