What is deep learning?
Deep learning is a subset of machine learning in Artificial Intelligence (AI) that has networks capable of learning unsupervised from data that is unstructured or unlabeled. Also known as Deep Neural Learning or Deep Neural Network.Prerequisites
- Deep learning tool box
- Alexnet add-on
Installing Alexnet Add-on
You can install this add-on from the menu,home->addons
and search for alexnet and click on install. Image classification using Alexnet
Alexnet
is a CNN (Convolution Neural Network) designed in 2012 at University of Toronto, read more about it hereMatlab’s deep learning toolbox has this built-in function which can be used for image classification, consider the example below,Create a new script from the menu, New -> Script
and copy the following snippet in the script and execute it using run
icon.Make sure that the image is present in the directory where the script is saved, if not you can define in a more concrete manner like $User/Pictures/monkey.jpeg
for linux and –E:/monkey.jpeg
depending on where you have it saved. So, let’s create the script from the snippet below and save it to say, alexExample.m
net=alexnet; I = imread('monkey.jpeg'); I = imresize(I, [227,227]); sz = net.Layers(1).InputSize; I = I(1:sz(1),1:sz(2),1:sz(3)); figure imshow(I) label = classify(net,I)Please note that the size of picture should be equal to the network in order for it to evaluate. This is a condition, so we need to resize & crop it to that size. The image size here 227 x 227 is hard-coded based on the size of the neural network.
Result
label = categorical macaqueFinally, as we can see that the output displays the resized image with the classification result
macaque
Please make sure that you have deep learning toolbox and alexnet addon already installed on your matlab before starting this example.