0% found this document useful (0 votes)
170 views3 pages

Pretrained Convolutional Neural Network - MATLAB & Simulink - MathWorks India

The document discusses using a pretrained convolutional neural network called AlexNet for feature extraction and transfer learning. It describes how to install the pretrained AlexNet model in MATLAB and use it to classify images by extracting features from the model or retraining the last few layers on a new dataset.

Uploaded by

savisu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views3 pages

Pretrained Convolutional Neural Network - MATLAB & Simulink - MathWorks India

The document discusses using a pretrained convolutional neural network called AlexNet for feature extraction and transfer learning. It describes how to install the pretrained AlexNet model in MATLAB and use it to classify images by extracting features from the model or retraining the last few layers on a new dataset.

Uploaded by

savisu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

26/12/2016

PretrainedConvolutionalNeuralNetworkMATLAB&SimulinkMathWorksIndia

PretrainedConvolutionalNeuralNetwork
TrainingConvolutionalNeuralNetworks(ConvNets)canbedifficultandtimeconsuming.Insomecases,itmakessenseto
startwithaConvNetalreadytrainedonalargedatasetandthenadaptittothecurrentproblem.Youcanuseapreviously
trainednetworkfortwopurposes:
FeatureextractionUsetheConvNettoextractfeaturesfromdata(images)andthenusethosefeaturestotraina
differentclassifier,e.g.,asupportvectormachine(SVM).
TransferlearningTakeanetworktrainedonalargedatasetandretrainthelastfewlayersonasmallerdataset.
TheCaffeversion[1]ofAlexNet,asdescribedin[2],isavailabletodownloadanduseforyourproblems.Thenetworkis
trainedonasubsetoftheimagesfromImageNetdatabase[3],whichareusedinImageNetLargeScaleVisualRecognition
Challenge(ILSVRC).Thereare1000categoriesandabout1000trainingimagesineachcategory.
YoucaninstallthetrainednetworkfromtheAddOnsgallery.SelectGetAddOnsfromtheAddOnsdropdownmenuofthe
MATLABdesktop.Theaddonfilesareinthe"MathWorksFeatures"section.ChooseNeuralNetworkToolboxModelfor
AlexNetNetwork.Tolearnmoreaboutfindingandinstallingaddons,seeGetAddOns.
Afteryoudownloadthesupportpackage,youcanaccessitbytypingalexnetinthecommandline.
net=alexnet
net=
SeriesNetworkwithproperties:
Layers:[251nnet.cnn.layer.Layer]
ThetrainednetworkisaSeriesNetworkobject.Youcanseethedetailsofthearchitecturebyusingdotnotation.
net.Layers
ans=
25x1Layerarraywithlayers:

1'data'ImageInput227x227x3imageswith'zerocenter'normalization
2'conv1'Convolution9611x11x3convolutionswithstride[44]andpadding[0
3'relu1'ReLUReLU
4'norm1'CrossChannelNormalizationcrosschannelnormalizationwith5channelsperelement
5'pool1'MaxPooling3x3maxpoolingwithstride[22]andpadding[00]
6'conv2'Convolution2565x5x48convolutionswithstride[11]andpadding[2
7'relu2'ReLUReLU
8'norm2'CrossChannelNormalizationcrosschannelnormalizationwith5channelsperelement
9'pool2'MaxPooling3x3maxpoolingwithstride[22]andpadding[00]
10'conv3'Convolution3843x3x256convolutionswithstride[11]andpadding[
11'relu3'ReLUReLU
12'conv4'Convolution3843x3x192convolutionswithstride[11]andpadding[
13'relu4'ReLUReLU
14'conv5'Convolution2563x3x192convolutionswithstride[11]andpadding[
15'relu5'ReLUReLU
16'pool5'MaxPooling3x3maxpoolingwithstride[22]andpadding[00]
17'fc6'FullyConnected4096fullyconnectedlayer
18'relu6'ReLUReLU
19'drop6'Dropout50%dropout
https://in.mathworks.com/help/nnet/ug/installtrainedconvolutionaldeepnetwork.html

1/3

26/12/2016

PretrainedConvolutionalNeuralNetworkMATLAB&SimulinkMathWorksIndia

20'fc7'FullyConnected4096fullyconnectedlayer
21'relu7'ReLUReLU
22'drop7'Dropout50%dropout
23'fc8'FullyConnected1000fullyconnectedlayer
24'prob'Softmaxsoftmax
25'output'ClassificationOutputcrossentropywith'tench','goldfish',and998othercla
Supposeyouwanttoclassifyanimageusingthistrainednetwork.First,readtheimagetoclassify.
I=imread('peppers.png');
Thisimageisofsize384by512by3.Youmustadjustittothesizeoftheimagesthenetworkwastrainedon.Extractthe
inputsizeofthenetwork.
sz=net.Layers(1).InputSize
sz=
2272273
Cropimagetotheinputsizeofthenetwork.
I=I(1:sz(1),1:sz(2),1:sz(3));
Classify(predictthelabelof)theimageusingAlexNet.
label=classify(net,I)
label=
bellpepper
classifyisamethodofSeriesNetwork.Showtheimageandtheclassificationresults.
figure
imshow(I)
text(10,20,char(label),'Color','white')

https://in.mathworks.com/help/nnet/ug/installtrainedconvolutionaldeepnetwork.html

2/3

26/12/2016

PretrainedConvolutionalNeuralNetworkMATLAB&SimulinkMathWorksIndia

References
[1]https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet
[2]Krizhevsky,A.,I.Sutskever,andG.E.Hinton."ImageNetClassificationwithDeepConvolutionalNeuralNetworks.
"AdvancesinNeuralInformationProcessingSystems.Vol25,2012.
[3]http://www.imagenet.org/

SeeAlso
activations|classify|predict|SeriesNetwork

RelatedExamples
TransferLearningUsingConvolutionalNeuralNetworks

https://in.mathworks.com/help/nnet/ug/installtrainedconvolutionaldeepnetwork.html

3/3

You might also like