- 'convolution2dLayer': https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.convolution2dlayer.html
- 'batchNormalizationLayer': https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.batchnormalizationlayer.html
how can i add feature map to the CNN before fullyConnectedLayer ?
3 views (last 30 days)
Show older comments
layers = [
imageInputLayer([width,height,channels]); %'DataAugmentation', 'none'); %'Normalization', 'none');
convolution2dLayer(2,16,'Padding',1)
batchNormalizationLayer
reluLayer
here add feature map
fullyConnectedLayer(12)
softmaxLayer
classificationLayer];
0 Comments
Answers (1)
Shantanu Dixit
on 21 Jan 2025
Edited: Shantanu Dixit
on 21 Jan 2025
Hi Amir,
To add a feature map in a neural network you can typically add more convolutional layers, which are responsible for detecting features in an image. In the context of your MATLAB code, you can add additional "convolution2dLayer" followed by "batchNormalizationLayer" and "reluLayer" to expand the feature map. Here's how you can modify your code:
% example height width and channels
width = 28;
height = 28;
channels = 1;
%% To calculate the output size of each layer, you can use the formula:
%% output feature size = floor( (Input size + 2*(padding) - filter size) / stride) + 1
%% layer = convolution2dLayer(filterSize,numFilters,Name=Value)
layers = [
imageInputLayer([width, height, channels])
convolution2dLayer(2, 16, 'Padding', 1)
batchNormalizationLayer
reluLayer
convolution2dLayer(3, 32, 'Padding', 1)
batchNormalizationLayer
reluLayer
convolution2dLayer(3, 64, 'Padding', 1)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(12)
softmaxLayer
];
Additionally you can refer to the following MathWorks documentation for more information:
Hope this helps!
0 Comments
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!