Recently studied a few days of deep learning of the MATLAB Toolbox code, found that the author gives the source of the comments is very poor, in order to facilitate everyone to read, the code has been commented, share with you.
Before reading the MATLAB Toolbox code, we recommend that you read a few CNN two classic materials, the convolutional neural Network MATLAB Toolbox Code understanding is very helpful, I will later upload these two articles to share with you online. The urgent need can also leave a message to indicate, I will send to the mailbox in time.
(1) "Notes on convolutional neural Networks", this article is a reference to the MATLAB Toolbox code, but there are two training parameters at the next sampling layer in the literature, the lower sample layer in the toolbox does not have the training parameters, the next sampling operation.
(2) "CNN Learning-Shikayu", which is related to the "Notes on convolutional neural Networks" content and similar to a Chinese PPT, the introduction of convolutional neural network is also easy to understand.
(3) deep learning MATLAB Toolbox Github:https://github.com/rasmusbergpalm/deeplearntoolbox
Here is a sample program for the CNN program on the Mnist database in the Toolbox:
%%=========================================================================% main function: Experiment on the Mnist database to verify the effectiveness of the Toolbox Algorithm flow: 1) Load the training sample and test sample% 2) Set the CNN parameter and do the training% 3) to detect cnntest ()% Note: 1) Since the input of all test samples directly leads to memory overflow, a test method is used to test only one training sample at a time%%= ========================================================================%%%%%%%%%%%%%%%%%%%%%% Loading Data Set%%%%%%%%%%%% %%%%%%%%load mnist_uint8;train_x = double (reshape (train_x ', 28,28,60000))/255;test_x = double (reshape (test_x ', 28,28,10000))/255;train_y = double (train_y '); test_y = double (test_y ');%%%%======================================== =================================%%%%%%%%%%%%%%%%%%%% setting convolutional neural network parameters%%%%%%%%%%%%%%%%%%%%% Main function: Training a 6c-2s-12c-2s form of convolutional neural network, the expected performance is as follows:% 1) The iteration takes about 200 seconds, the error rate is approximately 11% 2) the error rate after iteration 100 is approximately 1.2% the algorithm flow: 1) build neural networks and train , save in the form of a CNN structure% 2) test with a known training sample% Note: 1) before the test to prompt memory overflow, and then inexplicably did not overflow, estimated the system's memory threshold%%================================ =========================================rand (' state ', 0) cnn.layers = {struct (' type ', ' I ') % input layer struct (' type ', ' C ', ' Outputmaps ', 6, ' Kernelsize ', 5)% convolutional layer struct (' type ', ' s ', ' scale ', 2)% below the sample layer struct (' type ', ' C ', ' outputmaps ', ' kernelsize ', ' 5 ')% convolutional layer struct (' type ', ' s ', ' SCA Le ', 2)% under sample layer};CNN = Cnnsetup (CNN, Train_x, train_y); Opts.alpha = 1;opts.batchsi Ze = 50;opts.numepochs = 5;cnn = Cnntrain (CNN, Train_x, Train_y, opts); save Cnn_5 Cnn;load cnn_5; [er, bad] = Cnntest (CNN, Test_x, Test_y); Plot (CNN.RL); assert (er<0.12, ' Too big error ');
Next, you'll get the URL for the program notes for the CNN section in the Toolbox:
(1) deep learning Matlab Toolbox code Comment--cnnsetup.m:http://blog.csdn.net/u013088062/article/details/48662121
(2) deep learning Matlab Toolbox code Comment--cnntrain.m:http://blog.csdn.net/u013088062/article/details/48662247
(3) deep learning Matlab Toolbox code Comment--cnnff.m:http://blog.csdn.net/u013088062/article/details/48662303
(4) deep learning Matlab Toolbox code Comment--cnnbp.m:http://blog.csdn.net/u013088062/article/details/48662349
(5) deep learning Matlab Toolbox code Comment--cnnapplygrads.m:http://blog.csdn.net/u013088062/article/details/48662397
Deep Learning MATLAB Toolbox code detailed