How do I find out the number of neurons?

9 views (last 30 days)
Anindya Athaya Putri
Anindya Athaya Putri on 29 Jul 2021
Answered: Shivam Singh on 12 Aug 2021
Dear all,
I have this code for training neural network
Dataset = imageDatastore('Dataset', 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
[Training_Dataset, Validation_Dataset, Testing_Dataset] = splitEachLabel(Dataset, 0.7, 0.15, 0.15);
net = googlenet;
Input_Layer_Size = net.Layers(1).InputSize(1:2);
Resized_Training_Dataset = augmentedImageDatastore(Input_Layer_Size ,Training_Dataset);
Resized_Validation_Dataset = augmentedImageDatastore(Input_Layer_Size ,Validation_Dataset);
Resized_Testing_Dataset = augmentedImageDatastore(Input_Layer_Size, Testing_Dataset);
Feature_Learner = net.Layers(142).Name;
Output_Classifier = net.Layers(144).Name;
Number_of_Classes = numel(categories(Training_Dataset.Labels));
New_Feature_Learner = fullyConnectedLayer(Number_of_Classes, ...
'Name', 'PV Feature Learner', ...
'WeightLearnRateFactor', 10, ...
'BiasLearnRateFactor', 10);
New_Classifier_Layer = classificationLayer('Name', 'PV Classifier');
Network_Architecture = layerGraph(net);
New_Network = replaceLayer(Network_Architecture, Feature_Learner, New_Feature_Learner);
New_Network = replaceLayer(New_Network, Output_Classifier, New_Classifier_Layer);
Minibatch_Size = 4;
Validation_Frequency = floor(numel(Resized_Training_Dataset.Files)/Minibatch_Size);
Training_Options = trainingOptions('sgdm', ...
'MiniBatchSize', Minibatch_Size, ...
'MaxEpochs', 15, ...
'InitialLearnRate', 3e-4, ...
'Shuffle', 'every-epoch', ...
'ValidationData', Resized_Validation_Dataset, ...
'ValidationFrequency', Validation_Frequency, ...
'Verbose', false, ...
'Plots', 'training-progress');
net = trainNetwork(Resized_Training_Dataset, New_Network, Training_Options);
I need to know how many neurons are in layers? Does anyone have any idea?

Answers (1)

Shivam Singh
Shivam Singh on 12 Aug 2021
You can display the total number of learnable parameters of each layer in the output displayed by analyzeNetwork function by clicking on the arrow in the top-right corner of the layer table and selecting “Total Learnables”.
As of the current release there is no straightforward way to find the Total number of Learnables of the network. This is known to the concerned people, and they might provide support to this feature in the future release.

Community Treasure Hunt

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

Start Hunting!