I am working on a multilayer perceptron classifier (on fisher iris data set, so multiclass classification) and I am getting the above mentioned(on the title of this question) error. I do not know why, since my matrices have same rows and columns. Everything seems to be correct, but obviously something's not!
CODE:
% Perceptron(Multilayer perceptron)
% coding (+1/-1) of 3 classes
a = [-1 -1 +1]';%'//
b = [-1 +1 -1]';%'//
c = [+1 -1 -1]';%'//
% define training inputs
rand_ind = randperm(50);
trainSeto = meas(rand_ind(1:35),:);
trainVers = meas(50 + rand_ind(1:35),:);
trainVirg = meas(100 + rand_ind(1:35),:);
trainInp = [trainSeto trainVers trainVirg];
% define targets
T = [repmat(a,1,length(trainSeto)) repmat(b,1,length(trainVers))
repmat(c,1,length(trainVirg))];
So, what is wrong with my code and how could I fix it?
Could anyone help me?
meas=rand(200,4);
a = [-1 -1 +1]';%'//
b = [-1 +1 -1]';%'//
c = [+1 -1 -1]';%'//
% define training inputs
rand_ind = randperm(50);
trainSeto = meas(rand_ind(1:35),:);
trainVers = meas(50 + rand_ind(1:35),:);
trainVirg = meas(100 + rand_ind(1:35),:);
trainInp = [trainSeto trainVers trainVirg];
% define targets
tmp1 = repmat(a,1,length(trainSeto));
tmp2 = repmat(b,1,length(trainVers));
tmp3 = repmat(c,1,length(trainVirg));
T = [tmp1 tmp2 tmp3];
clear tmp1 tmp2 tmp3 %// Used for cleaning the temporaries
I think MATLAB has difficulties processing the three repmat
calls within the concatenation operator ([]
). i.e. I think it tries to repmat
the first, but gets stuck on how and when to repmat
the second. If you define temporary variables it works fine. You can use a clear
call if you do not want the temporaries to clutter your workspace.