rasmusbergpalm / DeepLearnToolbox

Matlab/Octave toolbox for deep learning. Includes Deep Belief Nets, Stacked Autoencoders, Convolutional Neural Nets, Convolutional Autoencoders and vanilla Neural Nets. Each method has examples to get you started.
BSD 2-Clause "Simplified" License
3.78k stars 2.28k forks source link

Error in cnnbp.m while using CNN #156

Open AviiGupta opened 8 years ago

AviiGupta commented 8 years ago

There is an error in cnnbp.m file, which said that

//////////////////////////////////////////////// “Undefined function ‘expand’ for input arguments of type ‘double’.” in the following line:

net.layers{l}.d{j} = net.layers{l}.a{j} .* (1 – net.layers{l}.a{j}) .* (expand(net.layers{l + 1}.d{j}, [net.layers{l + 1}.scale net.layers{l + 1}.scale 1]) / net.layers{l + 1}.scale ^ 2);

//////////////////////////////////////////////

Please let me know if I am making any error in parameter selection that may have resulted in this issue. The details of the parameter along with data set are as follows -

  1. dim(train_x) = 29x29x131072
  2. dim(train_y) = 4x1x131072

similarly test data sets.

Now, number of layers = 5 as per default in the test_example_CNN. With kernel size = 3 in both layer 2 & 4. Scale factor is set to be 3 in layer 3 and 7(just for trial purposes) in layer 5.

opts.alpha = 1 opts.batchsize = 64 opts.numepochs = 1

scoard commented 4 years ago

you shou add a function to do this, the purpose of the matrix expansion. /////////////////////////////////////////////////////////////////////////////////////////////////

function expand_bp = expand_cnn(x,y) expand_bp = zeros(size(x,1)y(1),size(x,2)y(2),size(x,3)y(3)); % test_column = zeros(size(x,1)y(1),size(x,2)y(2),size(x,3));;% column operation test_row = zeros(size(x,1)y(1),size(x,2),size(x,3)); % row operation row_row = y(1); column_column = y(2); heigh_heigh = y(3); for n =1: size(x,3) % row operation for row = 1:size(x,1) while row_row>0 test_row(y(1)row-(row_row-1),:,n) = x(row,:,n); row_row = row_row-1; end row_row = y(1); end % column operation for column = 1:size(x,2) while column_column>0 test_column(:,(y(2)column-(column_column-1)),n) = test_row(:,column,n); column_column = column_column-1; end column_column = y(2); end % third dimension while heigh_heigh>0 expand_bp(:,:,y(3)*n-(heigh_heigh-1)) = test_column(:,:,n); heigh_heigh = heigh_heigh-1; end heigh_heigh = y(3); end