Switch branches/tags
Nothing to show
Clone or download

This is a forward-path implementation of the CNN AlexNet. Starting with the ILSVRC 2012 competition, Convolutional Neural Networks (CNNs) proved to be state-of-the-art algorithm for image classification and detection. This straight-forward Matlab implementation of AlexNet forward path (also called CaffeNet) doesn't rely on any 3rd-party library.

Detect images

In your Matlab console, type


This will run AlexNet in forward path to detect a cat.

Understanding Forward Propagation

There are lots of highly optimized deep learning tools out there, like Berkeley's Caffe, Theano, Torch or Google's TensorFlow. Those tools will help you train and test your CNNs at high speed. However if you are new to deep learning, those tools won't help you much to understand the forward path of a CNN.

The goal of this project is to show you how forward-propagation works exactly in a quick and easy-to-understand way.

Every CNN is a concatenation of different layers. For more details about the different layers of AlexNet, please refer to my post on our research group's web page.

Implementation details

The network is implemented like Caffe's CaffeNet definition. The data between the layers is stored similar to Matcaffe. Each layer converts a 3d matrix (or 2d matrix for dense layers) bottom into the output top. The data between the layers is stored in width W x height H x channels N matrices. All network parameters are stored in 4d matrices.

Network parameters from Matcaffe

The network parameters are not included in this repository. Before running, please make sure you have the parameters of the trained network available. You can download the pretrained model from Caffe's Model Zoo and use Matcaffe to extract the network weights as *.mat file. Alternatively, you can download the weights here. When you run AlexNet in forward path, you will be prompted to select the MAT-file with those weights.

Resource Files

  • cat.jpg: The detection runs on this image.
  • ilsvrc_2012_mean.mat: The average of the ILSVRC image data base.
  • synset_words.txt: The 1000 ILSVRC image classes.


Our research group is working on hardware acceleration of deep CNNs. If this project helped your research, please kindly cite our latest conference paper:

Mohammad Motamedi, Philipp Gysel, Venkatesh Akella and Soheil Ghiasi, “Design Space Exploration of FPGA-Based Deep Convolutional Neural Network”, IEEE/ACM Asia-South Pacific Design Automation Conference (ASPDAC), January 2016.