cnnsetup.m problems in deep learning toolbox

11 ビュー (過去 30 日間)
MiMad
MiMad 2016 年 3 月 20 日
コメント済み: MiMad 2016 年 3 月 21 日
Hello, when l try to execute my code (cnn classifier) using deep learning toolbox http://www.mathworks.com/matlabcentral/fileexchange/38310-deep-learning-toolbox
l got this error from cnnsetup.m of deep learning toolbox : *Index exceeds matrix dimensions.
Error in cnntrain (line 14) batch_y = y(:, kk((l - 1) * opts.batchsize + 1 : l * opts.batchsize));
Error in cnn_classifier (line 43) cnn = cnntrain(cnn, train_x, train_y, opts);*
Here is my code of cnn_classifier.m
% load training set and testing set
clear all;
train_set = loadMNISTImages('/home/anelmad/Desktop/TER/mnist_ml2/MNIST_digit_recognition-master/load_data/train-images.idx3-ubyte'); % 60000 x 784
train_label = loadMNISTLabels('/home/anelmad/Desktop/TER/mnist_ml2/MNIST_digit_recognition-master/load_data/train-labels.idx1-ubyte'); % 60000 x 1
test_set = loadMNISTImages('/home/anelmad/Desktop/TER/mnist_ml2/MNIST_digit_recognition-master/load_data/t10k-images.idx3-ubyte'); % 10000 x 784
test_label = loadMNISTLabels('/home/anelmad/Desktop/TER/mnist_ml2/MNIST_digit_recognition-master/load_data/t10k-labels.idx1-ubyte'); % 10000 x 1
% trasform the data format
N = 10; % N is the number of output neurons
Y = eye(N);
train_size = size(train_set);
test_size = size(test_set);
train_y = zeros(train_size(1), N); % train_label to train_y 60000 x 10
test_y = zeros(test_size(1), N); % test_label to test_y 10000 x 10
for i=1:train_size(1)
train_y(i,:) = Y(train_label(i)+1,:);
end
for i=1:test_size(1)
test_y(i,:) = Y(test_label(i)+1,:);
end
% use the code of DeepLearnToolbox
train_x = double(reshape(train_set',28,28,60000));
test_x = double(reshape(test_set',28,28,10000));
train_y = double(train_y');
test_y = double(test_y');
% parameter setting
rand('state',0)
cnn.layers = {
struct('type', 'i') %input layer
struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer
struct('type', 's', 'scale', 2) %sub sampling layer
struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer
struct('type', 's', 'scale', 2) %subsampling layer
};
cnn = cnnsetup(cnn, train_x, train_y);
opts.alpha = 1;
opts.batchsize = 50;
opts.numepochs = 100;
cnn = cnntrain(cnn, train_x, train_y, opts);
[er, bad] = cnntest(cnn, test_x, test_y);
%plot mean squared error
figure; plot(cnn.rL);
assert(er<0.12, 'Too big error');
  1 件のコメント
MiMad
MiMad 2016 年 3 月 21 日
l don't understand index exceed matrix dimensions

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by