Explanation Alexnet in deep learning ?
4 ビュー (過去 30 日間)
古いコメントを表示
i need someone to explain me the following question:
this is a part of my code, my question is:
1. coluld you please write some explanation comment only for the following part of code only for (emoveLayers ,inputLayer, replaceLayer , addLayers and connectLayers.
2. i think this code is the same work when we modify AlexNet in (deepNetworkDesigner) am i right or not? or is there any different between 2 ways (manually/deepNetworkDesigner and coding) as below code?
lgraph = layerGraph(net.Layers);
lgraph = removeLayers(lgraph, 'fc8'); %please comment here for explanation ???
lgraph = removeLayers(lgraph, 'prob');
lgraph = removeLayers(lgraph, 'output');
% create and add layers
inputLayer = imageInputLayer([imageSize 1], 'Name', net.Layers(1).Name,... %please comment here
'DataAugmentation', net.Layers(1).DataAugmentation, ...
'Normalization', net.Layers(1).Normalization);
lgraph = replaceLayer(lgraph,net.Layers(1).Name,inputLayer);
newConv1_Weights = net.Layers(2).Weights;
newConv1_Weights = mean(newConv1_Weights(:,:,1:3,:), 3); % taking the mean of kernal channels
newConv1 = convolution2dLayer(net.Layers(2).FilterSize(1), net.Layers(2).NumFilters,...
'Name', net.Layers(2).Name,...
'NumChannels', inputLayer.InputSize(3),...
'Stride', net.Layers(2).Stride,...
'DilationFactor', net.Layers(2).DilationFactor,...
'Padding', net.Layers(2).PaddingSize,...
'Weights', newConv1_Weights,...BiasLearnRateFactor
'Bias', net.Layers(2).Bias,...
'BiasLearnRateFactor', net.Layers(2).BiasLearnRateFactor);
lgraph = replaceLayer(lgraph,net.Layers(2).Name,newConv1); %please comment here for explanation ?
lgraph = addLayers(lgraph, fullyConnectedLayer(numClasses,'Name', 'fc2'));
lgraph = addLayers(lgraph, softmaxLayer('Name', 'softmax'));%please comment here for explanation ?
lgraph = addLayers(lgraph, classificationLayer('Name','output'));
lgraph = connectLayers(lgraph, 'drop7', 'fc2');%please comment here for explanation ???
lgraph = connectLayers(lgraph, 'fc2', 'softmax');
lgraph = connectLayers(lgraph, 'softmax', 'output');
% -------------------------------------------------------------------------
0 件のコメント
採用された回答
Mohammad Sami
2020 年 9 月 7 日
This code is for transfer learning. That is when you already have a pretrained model that you wish to use for another purpose. The process is explained in detail in MATLAB's documentation.
Using Deep Network Designer:
Usign Manual Method:
Since the network was trained with different classes then your current purpose, you have to remove the final few layers at least from the last fully connected layer onwards. This is because the final fully connected layer needs to have the same output size as the number of classess in your data.
You then have to have to create new layers for the layers that you removed. The new fully connected layer has the output size which matches the number of classes in your data. Finally you can add these newly connected layers to complete your network.
3 件のコメント
Mohammad Sami
2020 年 10 月 2 日
Deep network designer is a convenient app to help you design / edit a network. Once you have edited to your satisfaction you can export it as code. You can always do the same directly in code.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!