File Exchange Pick of the Week

Our best user submissions

Deep Learning for Image Classification

Deep Learning for Image Classification

Avi’s pick of the week is the Deep Learning Toolbox Model for AlexNet Network, by The Deep Learning Toolbox Team. AlexNet is a pre-trained 1000-class image classifier using deep learning more specifically a convolutional neural networks (CNN). The support package provides easy access to this powerful model to help quickly get started with deep learning in MATLAB.

Contents

Access the pre-trained model in MATLAB

Once you have downloaded and installed the support package, you can load the pre-trained model into MATLAB.

net = alexnet
net = 

  SeriesNetwork with properties:

    Layers: [25×1 nnet.cnn.layer.Layer]

View network architecture

Now let’s take a quick look at the structure of the deep neural network layers.

net.Layers
ans = 

  25x1 Layer array with layers:

     1   'data'     Image Input                   227x227x3 images with 'zerocenter' normalization
     2   'conv1'    Convolution                   96 11x11x3 convolutions with stride [4  4] and padding [0  0]
     3   'relu1'    ReLU                          ReLU
     4   'norm1'    Cross Channel Normalization   cross channel normalization with 5 channels per element
     5   'pool1'    Max Pooling                   3x3 max pooling with stride [2  2] and padding [0  0]
     6   'conv2'    Convolution                   256 5x5x48 convolutions with stride [1  1] and padding [2  2]
     7   'relu2'    ReLU                          ReLU
     8   'norm2'    Cross Channel Normalization   cross channel normalization with 5 channels per element
     9   'pool2'    Max Pooling                   3x3 max pooling with stride [2  2] and padding [0  0]
    10   'conv3'    Convolution                   384 3x3x256 convolutions with stride [1  1] and padding [1  1]
    11   'relu3'    ReLU                          ReLU
    12   'conv4'    Convolution                   384 3x3x192 convolutions with stride [1  1] and padding [1  1]
    13   'relu4'    ReLU                          ReLU
    14   'conv5'    Convolution                   256 3x3x192 convolutions with stride [1  1] and padding [1  1]
    15   'relu5'    ReLU                          ReLU
    16   'pool5'    Max Pooling                   3x3 max pooling with stride [2  2] and padding [0  0]
    17   'fc6'      Fully Connected               4096 fully connected layer
    18   'relu6'    ReLU                          ReLU
    19   'drop6'    Dropout                       50% dropout
    20   'fc7'      Fully Connected               4096 fully connected layer
    21   'relu7'    ReLU                          ReLU
    22   'drop7'    Dropout                       50% dropout
    23   'fc8'      Fully Connected               1000 fully connected layer
    24   'prob'     Softmax                       softmax
    25   'output'   Classification Output         cross-entropy with 'tench', 'goldfish', and 998 other classes

Classify image

Now lets try and classify an image using deep learning. We need to resize the input images to match the input of the network that is 227 x 227 pixels before classifying the image.

I = imread('Keyboard.jpg');

% Adjust size of the image
sz = net.Layers(1).InputSize
I = imresize(I,[sz(1) sz(2)]);

% Classify the image using AlexNet
label = classify(net, I)

% Show the image and the classification results
figure
imshow(I)
text(10,20,char(label),'Color','white')
sz =

   227   227     3


label = 

     typewriter keyboard 

potw_post_01

 

 

 

 

 

 

 

 

 

More Information on Deep Learning 

To learn more about deep learning and how to re-train the AlexNet model for a different task, take a look at the example in this webinar that uses AlexNet to distinguish between different kinds of tools.

 

 

 

|
  • print

コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。