File Exchange

image thumbnail

Neural Network Toolbox(TM) Model for AlexNet Network

Pretrained AlexNet network model for image classification

4.33333
41 Ratings

864 Downloads

Updated

Editor's Note: This file was selected as MATLAB Central Pick of the Week Popular File 2017

AlexNet is a pretrained Convolutional Neural Network (CNN) that has been trained on approximately 1.2 million images from the ImageNet Dataset (http://image-net.org/index). The model has 23 layers and can classify images into 1000 object categories (e.g. keyboard, mouse, coffee mug, pencil).
Opening the alexnet.mlpkginstall file from your operating system or from within MATLAB will initiate the installation process for the release you have.
This mlpkginstall file is functional for R2016b and beyond.
Usage Example:
% Access the trained model
net = alexnet
% See details of the architecture
net.Layers
% Read the image to classify
I = imread('peppers.png');
% Adjust size of the image
sz = net.Layers(1).InputSize
I = I(1:sz(1),1:sz(2),1:sz(3));
% 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')

Comments and Ratings (109)

I'm using Matlab R2015a. Could you please send me a .zip file to my email: usmansuleiman5050@yahoo.com. Many thanks

YanNuan Li

Daniel Paz

I'm using Matlab 2015a. Could you please send me a .zip file to my email: danielvalor06@gmail.com. Many thanks

Carter Wang

I am using R2016a. Please send me .zip file at alan6115yes@gmail.com Thanks in advance.

Anna Gaffney

I am using Matlab 2015a. Please send me a .zip file to my email: annagaff@umich.edu. Thank you!

Oindri

Oindri (view profile)

I am using R2016a. Please send me .zip file at oindrimajumdar91@outlook.com. Thanks in advance.

I am using Matlab 2015a. Please send me .zip file to my email: shimanofarid@gmail.com. Thanks

Scott Baldwin

This package with the transfer learning tutorial/script has been excellent for me! Thanks!

I have one question. In the AlexNet paper (Krizhevsky, et al. 2012), they reference dividing the CNN along two paths to distribute the tasks to two GPUs. However, this task division is not explicit in the net.Layers result for the pre-trained AlexNet.

Instead, we have this:

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 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 0 0]
6 'conv2' Convolution 256 5x5x48 convolutions with stride [1 1] and padding [2 2 2 2]

If the CNN is not being dividing along two different computation paths, then should conv2 actually be 5x5x96?

Does Matlab software automatically realize that 48 is half of 96 and divide the CNN accordingly?

Thanks,
Scott

XIN TANG

Nixon Dhar

please, can anyone share the alexnet file to me?
email:nixondhar.ustccse@gmail.com

I am using Matlab 2015a. Please send me .zip file to my email: panaree.chaipayom@gmail.com. Thanks.

Adaktk

Adaktk (view profile)

Please send me the zip file for install offline for MATLAB 2015a. The zip file for offline installation?
adaktk@gmail.com

taha khan

WATSON HUA

I can't install it for Matlab 2017a, can anyone send me .zip file to my mail hualuy@126.com. Thanks in advance!

PRATUL KUMAR`

I can't install it for Matlab 2017a, Matlab crashes automatically after opening add ons menu, can anyone send me .zip file to my mail pratulkumar1998@gmail.com. Thanks in advance!

I am using matlab R2016b. I can not install alexnet showing an error. Could you please send me .ZIP file to this email: dianalucia20@gmail.com. ThX

yang wang

Nixon Dhar

Can you please share alexnet for Matlab r2017a?
email: nixondhar.ustccse@gmail.com

Sophia Bano

I am unable to run the mlpkginstall file format on ubuntu 14.04 with Matlab2017b installed. Neither the Add-on button responds. Any idea how to solve this issue?

Can you send me the .zip file so that I can use it directly?

THanks

Zhiguo Tan

Could you please send me .ZIP file to this email: tanzhiguo@foxmail.com, for my computer is offline.

ing mecrat

perdone me podrían pasarme el paquete de AlexNet sal.moreno02@gmail.com gracias

I have Matlab 2015a version, is there any possibility to install this package on this version?!
Please send me .ZIP file to this email: arvindrvs21@gmail.com

rcjr15

rcjr15 (view profile)

Is there a way to install this support toolbox model using command line? without using GUI interface? I am facing a problem to install the same on our high-performance NeSI (New Zealand eScience Infrastructure) cluster?

Minh Pham

Kelen Lv

jixiang

Because my computer is offline,so could you please send me .ZIP file to this email: liqiaojixiag@gmail.com

Chi-Tsung

How to use alexnet to detect shadow from single image

durant ralph

Marianna Meo

Hi, I have the Neural Network Toolbox installed on Matlab 2015B version, but the message "Neural Network Toolbox Model for AlexNet Network is not available for this release of MATLAB" appears when I try to install the function. Any solutions for 2015B version?

Can you please share alexnet for Matlab R2015a?
email: dionisiohenrique@ig.com.br

mohammed

Ali Subhan

Can you please share alexnet for Matlab r2015a?
email: alisfire@hotmail.com

Alex Genescu

How can i install this on Matlab 2015a?
genescu_alex@yahoo.com

I am facing problem installing it, maybe its the reason that I have Matlab 2015a, Could you given me a probable solution for it?
My email is harishkongari255.hk@gmail.com

mohsin qurban

Dear MathWorks Neural Network Toolbox Team,

Thank you very much for sharing the pre-trained AlexNet with the Matlab community. I have noticed that, after loading AlexNet, I have the following structure:

1 'data' Image Input 227x227x3 images with 'zerocenter' normalization
2 'conv1' Convolution 96 11x11x3 convolutions with stride [4 4] and padding [0 0 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 0 0]
6 'conv2' Convolution 256 5x5x48 convolutions with stride [1 1] and padding [2 2 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 0 0]
10 'conv3' Convolution 384 3x3x256 convolutions with stride [1 1] and padding [1 1 1 1]
11 'relu3' ReLU ReLU
12 'conv4' Convolution 384 3x3x192 convolutions with stride [1 1] and padding [1 1 1 1]
13 'relu4' ReLU ReLU
14 'conv5' Convolution 256 3x3x192 convolutions with stride [1 1] and padding [1 1 1 1]
15 'relu5' ReLU ReLU
16 'pool5' Max Pooling 3x3 max pooling with stride [2 2] and padding [0 0 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 crossentropyex with 'tench', 'goldfish', and 998 other classes

I would like to replicate the same structure, but train it from scratch. My code is:

layers = [ ...
imageInputLayer([227 227 3])
convolution2dLayer([11 11],96,'Stride',[4 4],'Padding',[0 0 0 0])
reluLayer
crossChannelNormalizationLayer(5)
maxPooling2dLayer(3,'Stride',[2 2],'Padding',[0 0 0 0])
convolution2dLayer([5 5],256,'Stride',[1 1],'Padding',[2 2 2 2])
reluLayer
crossChannelNormalizationLayer(5)
maxPooling2dLayer(3,'Stride',[2 2],'Padding',[0 0 0 0])
convolution2dLayer([3 3],384,'Stride',[1 1],'Padding',[1 1 1 1])
reluLayer
convolution2dLayer([3 3],384,'Stride',[1 1],'Padding',[1 1 1 1])
reluLayer
convolution2dLayer([3 3],256,'Stride',[1 1],'Padding',[1 1 1 1])
reluLayer
maxPooling2dLayer(3,'Stride',[2 2],'Padding',[0 0 0 0])
fullyConnectedLayer(4096)
reluLayer
dropoutLayer(0.5)
fullyConnectedLayer(4096)
reluLayer
dropoutLayer(0.5)
fullyConnectedLayer(1000)
softmaxLayer
classificationLayer]

which gets me:

1 '' Image Input 227x227x3 images with 'zerocenter' normalization
2 '' Convolution 96 11x11 convolutions with stride [4 4] and padding [0 0 0 0]
3 '' ReLU ReLU
4 '' Cross Channel Normalization cross channel normalization with 5 channels per element
5 '' Max Pooling 3x3 max pooling with stride [2 2] and padding [0 0 0 0]
6 '' Convolution 256 5x5 convolutions with stride [1 1] and padding [2 2 2 2]
7 '' ReLU ReLU
8 '' Cross Channel Normalization cross channel normalization with 5 channels per element
9 '' Max Pooling 3x3 max pooling with stride [2 2] and padding [0 0 0 0]
10 '' Convolution 384 3x3 convolutions with stride [1 1] and padding [1 1 1 1]
11 '' ReLU ReLU
12 '' Convolution 384 3x3 convolutions with stride [1 1] and padding [1 1 1 1]
13 '' ReLU ReLU
14 '' Convolution 256 3x3 convolutions with stride [1 1] and padding [1 1 1 1]
15 '' ReLU ReLU
16 '' Max Pooling 3x3 max pooling with stride [2 2] and padding [0 0 0 0]
17 '' Fully Connected 4096 fully connected layer
18 '' ReLU ReLU
19 '' Dropout 50% dropout
20 '' Fully Connected 4096 fully connected layer
21 '' ReLU ReLU
22 '' Dropout 50% dropout
23 '' Fully Connected 1000 fully connected layer
24 '' Softmax softmax
25 '' Classification Output crossentropyex

Pretty close, but I notice I am missing one dimension on the filters. When I try to set three dimensions, e.g. convolution2dLayer([11 11 3],96,'Stride',[4 4],'Padding',[0 0 0 0]), I get the error:

Error using convolution2dLayer>iParseInputArguments (line 116)
The value of 'FilterSize' is invalid. FilterSize must be a scalar or a row vector of two scalar values.

Error in convolution2dLayer (line 91)
args = iParseInputArguments(varargin{:});

Would you be so kind to help me?

Thank you very much in advance,

Inês Domingues

prashu kr

my mail is kodurprashanth@gmail.com

prashu kr

sir!! even i am using matlab 2016a,plz guide me to install this alexanet

Slim Hamdi

I have Matlab 2015a version, is there any possibility to install this package on this version?!
Please send me .ZIP file to this email: hamdislimm@gmail.com

Why I cannot use Alexnet on my images dataset.

clc;
clear;
images = imageDatastore('C:\Users\HIBA\Documents\Cancellable Biometrics\Datasets\NIST Faces 1','IncludeSubfolders',true,'LabelSource','foldernames');
[trainingImages,testingImages] = splitEachLabel(images,0.7,'randomized');
net = alexnet;
net.Layers;
layer = 'fc7';
trainingFeatures = activations(net,trainingImages,layer,'outputAs','channels');
testFeatures = activations(net,testingImages,layer);

i am using matlab r2016a i can not install alexnet showing an error ,undeclared variable so i am new to this field can u mail the instructions how to download alex net..
potnuru.shivaji2017@vitstudent.ac.in

kunal gokhe

I have matlab R2017.b, Could you please send me the zip file for install offline?
kunalgokhe@gmail.com

Dear Coleagues, could you send me the offline package compatible to R2011a into g6029694@au.edu ?
thank you

Jonas Ortiz

Dear Coleagues, could you send me the offline package into jonas.ortiz@br.bosch.com?
thank you

Dear all, please send the offline package into endalewsimie@gmail.com if u can. thank u

Ahror BELAID

Dear , may you send me the package for offline installation ?
my email is : nnassime@yahoo.fr
Thankyou!

HELA LASS

Hi,
I'm using MATLAB 2015a. would you mind sending me The zip file for offline installation?
laswed.hela@gmail.com
Thanks,

Rafi Zaman

Hi, I have Matlab 2017a, and it is not downloading this package. may be its my internet or matlab down-loader problem which is not downloading through matlab. could any one kindly share downloaded package link?

Talha Rehman

Is this toolbox compatible with Matlab 2016b for macOS?

chao wei

Could not install on MATLAB R2016a,

Mohammad

Hi,
I'm using MATLAB 2015a. Can you please send me The zip file for offline installation?
jalaly.mohammad@gmail.com
Thanks,

hana razak

Hi,
I have Matlab R2015a. Could you please send me the zip file for install offline?
ladyhanarazak@gmail.com
Thank you

Ionut Barbu

@As Has: convert to 3-channel image with repmat
imgConverted = repmat(imgGrayscale, [1 1 3]) ;
should to the trick

anwer slimani

I have matlab R2015.a, Could you please send me the zip file for install offline?
gnaoui.kheriji@enis.tn

As Has

As Has (view profile)

how can i use alexnet , which trained on RGB images, with my gray level data ? should i convert my data into RGB ( computational time ) or convert the filter of alexnet layers into one channel (how ?)
thans

yun tang

someone who can't install it, just change your region and time zone to U.K. sir

I have matlab 2015, Could you please send me the zip file for install offline?
mostafa.elmallahi@hotmail.com

Keiko

Keiko (view profile)

yoga liu

Why con't I install it?? Matlab2016a

mage bryan

Interesting toolbox

Russ, unfortunately, you'd need an internet access to authenticate your account.

AlexNet does not work with 16a.

Is there another version that is suitable for MATLAB R2016a?

Russ White

How do you install an Add-On if you do have an internet connection? I have transferred download to a computer not connected to the internet.

Shounak Mitra

HI @Arnav, it is possible to do that!

Ryan Ruan

Arnav Singh

As i am doing a project on leaf recognition so Is it possible to use my own leaf database for this network instead of using alexnet pre-trained database?

Guojin Feng

Wang Collus

Very good inspiration for beginners. I think also useful for experienced ML users since one can use it for transfer learning.

Could you please send me the zip file for install offline?
k.aljabri1691@yahoo.com

huat

huat (view profile)

When i run the downloaded alexnet, matlab shows the wrong use of assert. What is the reason for that?

Hesam

Hesam (view profile)

When I run the code for classify(net, I)
i get the error of :
An unexpected error occurred during CUDA execution. The CUDA error was:
all CUDA-capable devices are busy or unavailable

How can I run it just by CPU as I Dnont have GPU on this machine?

why does the install page take so much time to load ? this is my issue

Mohsen

Mohsen (view profile)

YAWAR REHMAN

Nice. really appreciate!

NIce JOb!

ben nad

hi,
i have MATLAB R2016a, and i get this error "Neural Network Toolbox Model for AlexNet Network is not available for this release of MATLAB", need some help

Binjie Yuan

The exact error message should be : The support package is not compatible with your version of MATLAB or operating system. So do I have to return to matlab r2016b to uss this package?

Binjie Yuan

I'm using matlab r2017a on win7. I got this error during installation: the support package is incompatible with matlab or operating system.

Ming Lin

Hossein

How can I install this centrally so everyone using MATLAB can have access to this toolbox? My first attempt in installing it created a local instance under my home directory

Naveen Soni

Emad mosbah: because its start working from 2016b version

emad mosbah

hello , i need help , am tried to install this package and i get this erreur <<neural network tollboox model for Alexnet not avialable for this realise of matlab >> , i have matlab R2016a_win64

David

David (view profile)

Anamika jain

i need help. when i downloaded the package and when tried to install then the following error has been came.
https://localhost:61416/ui/install/supportsoftwareclient/supportsoftwareclient/index.html?workflowType=MLPKGINSTALL&installfolder=C:\ProgramData\MATLAB\SupportPackages\R2016b&basecode=ALEXNET&snc=191ED5 with erroe (-111)

Shyamal Patel

You can do the following to get all the class labels:

net = alexnet()
net.Layers(end).ClassNames

Hello. How can I find the complete list of possible labels?

Adam Filion

Adam Filion (view profile)

This does require R2016b. Works great on that version. Short video on getting started using it.

https://www.mathworks.com/videos/deep-learning-in-11-lines-of-matlab-code-1481229977318.html

sofi babu`

is it compatible for 2014b ??

Vladka Vit

I think you need Matlab version 2016b, I had the same problem with version 2016a.

JS

JS (view profile)

Could not install on my 2016 version

JS

JS (view profile)

Tommy

Tommy (view profile)

I have similar issue Matlab gives me the following error:

> In alexnet (line 46)
In MyFirstDeepLearningTest (line 4)
Error using classify (line 122)
Requires at least three arguments.

Error in MyFirstDeepLearningTest (line 11)
label = classify(nnet, picture);

-----------
When I look at classify in the help is pulling it from the Statistics and Machine learning toolbox. Do you know how to force to use the Classify from the neural net toolbox?

Gerd Kunert

Requires also "Parallel Computing Toolbox" and CUDA-enabled NVIDIA GPU with compute capability 3.0 or higher.

Please correct the description.
Unfortunately, this package is thus useless for me.

Shyamal Patel

Also, check out this submission that uses alexnet to classify objects in images captured by a webcam in real-time.
https://www.mathworks.com/matlabcentral/fileexchange/60659-deep-learning-in-11-lines-of-matlab-code

Shyamal Patel

Hi Stephen,
Looks like MATLAB is trying to use the classify function from Statistics & Machine Learning Toolbox.
https://www.mathworks.com/help/stats/classify.html

You want to use the classify function from the Neural Network Toolbox.
https://www.mathworks.com/help/nnet/ref/seriesnetwork.classify.html

Hope this helps,
Shyamal

Richard

I think this submission would more interesting, if Mathworks were to provide the code to actually train the model.

Stephen Westland

I am making progress. But I still have two issues.

When I run
nnet = alexnet;

I get

>> label = classify(nnet,I);
Error using classify (line 122)
Requires at least three arguments.

>> which alexnet
C:\ProgramData\MATLAB\SupportPackages\R2016b\toolbox\nnet\supportpackages\alexnet\alexnet.m
>> nnet = alexnet;
Warning: While loading an object of class 'SeriesNetwork':
Can't load 'C:\Program Files\MATLAB\R2016b\bin\win64\cnngpu.dll': The specified module could not be found.
> In alexnet (line 46)

When I try to use it with

label = classify(nnet,image);

I get

>> label = classify(nnet,I);
Error using classify (line 122)
Requires at least three arguments.

Any help or advice please?

Steve

Stephen Westland

didn't work for me

I have 2016b. I installed the file but when I tried to run it I received:
Can't reload 'C:\Program Files\MATLAB\R2016b\bin\win64\cnngpu.dll'
I restarted MATLAB.
When I then tried to click on the installation file I had the mes alexnet was not available for this release of MATLAB :(

Andy Stanton

Any way to run this package on R2016a?

Harsh

Harsh (view profile)

Hongjie Ma

to ZGCACI:

% Location of pre-trained "AlexNet"
cnnURL = 'http://www.vlfeat.org/matconvnet/models/beta16/imagenet-caffe-alex.mat';
% Store CNN model in a temporary folder
cnnMatFile = fullfile(tempdir, 'imagenet-caffe-alex.mat');
Note: Download time of the data depends on your internet connection. The next set of commands use MATLAB to download the data and will block MATLAB. Alternatively, you can use your web browser to first download the dataset to your local disk. To use the file you downloaded from the web, change the 'cnnMatFile' variable above to the location of the downloaded file.

ZGCACI

ZGCACI (view profile)

How might I extract alexnet.mlpkginstall file and run on offline computer where my 2016bMatlab is located? No way for me to run the support package installer from my offline computer.

Any help would be greatly appreciated. Thanks

Updates

Does not need PCT

Updated description

Updated logo image.

Added Parallel Computing Toolbox as a required product.

Changed title.

Requires MATLAB R2016b or higher

MATLAB Release
MATLAB 9.1 (R2016b)

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video