File Exchange

image thumbnail

Deep Learning Toolbox

version 1.2 (16 MB) by

Deep Belief Nets, Stacked Autoencoders, Convolutional Neural Nets and more. With examples.

49 Ratings



Editor's Note: Popular File 2014

Deprecation notice.
This toolbox is outdated and no longer maintained.

There are much better tools available for deep learning than this toolbox, e.g. Theano, torch or tensorflow

I would suggest you use one of the tools mentioned above rather than use this toolbox.

Best, Rasmus.

A Matlab toolbox for Deep Learning.
Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data. It is inspired by the human brain's apparent deep (layered, hierarchical) architecture. A good overview of the theory of Deep Learning theory is Learning Deep Architectures for AI

For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.

The Next Generation of Neural Networks (Hinton, 2007)
Recent Developments in Deep Learning (Hinton, 2010)
Unsupervised Feature Learning and Deep Learning (Ng, 2011)
If you use this toolbox in your research please cite:

Prediction as a candidate for learning deep hierarchical models of data (Palm, 2012)

Directories included in the toolbox
NN/ - A library for Feedforward Backpropagation Neural Networks

CNN/ - A library for Convolutional Neural Networks

DBN/ - A library for Deep Belief Networks

SAE/ - A library for Stacked Auto-Encoders

CAE/ - A library for Convolutional Auto-Encoders

util/ - Utility functions used by the libraries

data/ - Data used by the examples

tests/ - unit tests to verify toolbox is working

For references on each library check

Comments and Ratings (68)


Nawzat (view profile)

hello every one,
i would like to ask why when training dbn and fine tune the model using nn , then predict the model on test data the out_y get same index using nnff the nn.a{end} are the same values ( i used numeric data with 800 observations for binary classification)
thanks in advance

when i run on my dataset i have this error

Error using cnnsetup (line 9)
Layer 3 size must be integer. Actual: 19198 -1.5

Haiyan WANG

Yongca Zhao

Bowen Liu

Zero documentations, none of the code are commented, and the library throws errors with no explanations if any assert fails.

Bowen Liu

m sh

m sh (view profile)

zhenzhou wang

zhenzhou wang (view profile)

Not enough description. No clear goal!

I also am interested in knowing whether this package can be used for regression.

ahmad karim

Please asume that i have image how can i classified it by using cnn i cant implement the code

Can you explain about labeling? i.e, how did you labels for train and test data?


bam (view profile)

May i know the NN toolbox refer to DNN or conventional NN


M J (view profile)

Dear Karakule,
Please write your problems here to help you.


is there anyone who can help me. I didn't run any code. I have faced some problem and I didnt fix it. Please help me.


So, you won't update this toolbox any more, right? But it really works very well. Thank you for providing this.

works very good test_example_CNN.m
need to add paths

I am getting an error during executation of test_example_SAE. The error is

Attempted to access lmisys(4);
index out of bounds because

Error in lmiunpck (line 23)
rs=lmisys(4); rv=lmisys(5);
% row sizes of LMISET,LMIVAR

Error in nnsetup (line 26)

Error in saesetup (line 3){u-1} =
size(u) size(u-1)]);

Error in test_example_SAE (line
sae = saesetup([784 100]);


Shemmy (view profile)

Nan Ye

Nan Ye (view profile)

Eason Tseng

su jin an

I m getting an error saying it cant load mnist_uint8.
where can I get this dataset?
i tried using the mnist data from their website and it says some columns are not available due to ASCII.
Wil you help me please?

Karel Macek

Is it possible to use the Toolbox also for general regression?

Song weiwei

Very nice


Sorry, but the more i look the code the more i'm convinced that this si not as cool as it seems at first. True that there are no other libraries doing CAEs, but this is left unfinished.

Beware that even kernels don't work. Also you have to expect that the toolbox is strictly thought for image data.

Kai Zhang


This is a really nice toolbox, but as some say it lacks of a document and of code commenting.

May i ask what is the difference between input and output kernels in the Convolutional autoencoders? Why such a distinction is not done in the simple convolutional networks? And if i was to pre-train a CNN using a CAE how should i preceed?


I am getting this error:

Error using nntrain (line 33)
numbatches must be a integer

Which has to do with batchsize

I have used different number and all give me this error.
My training dataset contains 8150 datapoints
When I give nn.numbatches = 50;

I get this error.
Anyone any idea how to deal with this?
Not sure what to do


Nadith (view profile)

In nnff(), does anyone know why we use dropout fraction when testing ? Is'nt the testing supposed to be done with non-corrupted/manipulated data ?

Ref. source
if(nn.dropoutFraction > 0)

nn.a{i} = nn.a{i}.*(1 - nn.dropoutFraction);


nn.dropOutMask{i} = (rand(size(nn.a{i}))>nn.dropoutFraction);
nn.a{i} = nn.a{i}.*nn.dropOutMask{i};


Gustavo Mafra

Don't you have a bug in your rbmtrain function?

When I select the number of batches to be equal to one the codes sum(v1 - v2) and sum(h1 - h2) sum up to a scalar when in fact they should be a vector. I don't know if this is different for your version of MATLAB, but a simple fix in R2014a is simply adding a second parameter to the sum function like this: sum(v1 - v2, 1)

I haven't explored that much the library to say this issue is not present elsewhere

Java Xun

Hi, i tried to run DBN.m with my own data, but when I run this code:[er, bad] = nntest(nn, test_x, test_y);
I found er is zero and bad is null. the input size of train_x is 320*200,the output is 320*1. who could tell my why this happened ? Thanks

Aik Hong

Hi, i tried to run the test_example_DBN.m, i get the error below:

??? Attempted to access lmisys(5); index out of bounds because numel(lmisys)=4.

Error in ==> lmiunpck at 23
rs=lmisys(4); rv=lmisys(5); % row sizes of LMISET,LMIVAR

Error in ==> nnsetup at 26

Error in ==> dbnunfoldtonn at 10
nn = nnsetup(size);

is that something not right there? i didnt change anything in the code. Or is it something related to my Matlab version?

Po Sheng Wang

When I run the file of "test_example_CNN", I got the error of below
assert(~isOctave() ||
compare_versions(OCTAVE_VERSION, '3.8.0',
'>='), ['Octave 3.8.0 or greater is required
for CNNs as there is a bug in convolution in
previous versions. See Your
version is ' myOctaveVersion]);

It seems like my Octave is too old? So how can I update my Octave? Just download new Octave and install it and then everything will be great?? Thanks

I found the CNN library very informative for helping me learn more of the basics of Convolutional Neural Networks.

It's well written, though lacking in comments and documentation.

I wrote a post explaining the CNN example along with documented / commented versions of most of the CNN functions:


Hazem (view profile)

I can't understand the example, what is this data and what the example used for?


Hazem (view profile)

I can't understand the example, what is this data and what the example used for?


qu (view profile)

Is there someone who would like to tell me how to install it?

poor documentation makes this hardly usable.

for example:
function scae = scaesetup(cae, x, opts)
x = x{1};

code starts straight away without any parameter explaining. what is x? opts? cae?
you can look at the example code but it is hard to reverse engineer it.


Umer (view profile)

I just started using this code and was puzzled by the following (plz excuse me for my newbie questions):

How come the errors on MNIST in the examples are less than state of the art? I get ~0.07 error on the 2-layer DBN-NN in the example. State-of-the-art, as far as I am aware, is higher than this.

Also when visualizing the dbn.rbm{2}.W' layer I see pretty much garbage. There is no structure to the weights like dbn.rbm{1}.W'. What has to be done to enable higher level structure learning.

Jane Shen

How to download this valuable toolbox here... can only from GitHub?


BO (view profile)

nntest.m has an error: it will give all 1s for expected, rather than the column index for each row of y.

function [er, bad] = nntest(nn, x, y)
labels = nnpredict(nn, x);
expected = I;
bad = find(labels ~= expected);
er = length(bad) / size(x, 1);

It does not run under version R2014a. All tests crash.


Nadith (view profile)

The best cleanest code that anyone could get at the moment... :) Thanks a lot. I'm working on extending the network capabilities depending on my work.

Junhong YE


ming (view profile)

how can I download this toolbox? I really it.


Yao (view profile)


Yao (view profile)



Rania (view profile)

how can i download this file please?

Litao Shen

I have a problem about using the nnbp, there is nn.e in nnbp while in nnsetup nn has no e. What shoud I do?

Kazuhito Sato

Thanks for your code.
This code is very useful and exciting for me.

ted p teng

ted p teng (view profile)

Yong Ho

Thanks for your code! But, when I execute cnnexamples in CNN folder after modifying cnn.layers' kernel size from "5" to "4",
I got an error in cnnbp.m line 37 like "Array dimensions must match for binary array op."
please check this error message. Thanks.

Andrew Diamond

Andrew Diamond (view profile)

Just tried to run the 2nd DBN example and it failed. First, the assert at line 6 of rbmtrain.m failed. From what I see, the assert should be ==0 not ~= 0 (numbatches should be integer).

Secondly, the example failed on nnff line 14. From what I can tell, the last size size in dbn.sizes should be 10 as that's the y (==> output layer) size.


Thanks for your code! I would like to know if there is more documentation than the few examples that are given? Particularly for the cnn.layer in the CNN toolbox?


Al (view profile)


How do I find the probability of a label being selected with this code? I am new to neural networks and am just trying this toolbox out.



Jeff (view profile)


Ahmed (view profile)

Well written code that saved me a lot of time.

Sebastien PARIS





Changed to use GitHub

MATLAB Release
MATLAB 7.11 (R2010b)

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

» Watch video