简体   繁体   English

使用垂直时发生错误:串联的矩阵尺寸不一致

[英]Error using vertical: Dimensions of matrices being concatenated are not consistent

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 ( [] ). 我认为MATLAB难以处理串联运算符( [] )中的三个repmat调用。 ie I think it tries to repmat the first, but gets stuck on how and when to repmat the second. 即,我认为它尝试重新repmat第一个,但是卡在如何以及何时重新repmat第二个上。 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. 如果您不希望临时人员使工作空间混乱,则可以使用clear呼叫。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决:使用horzcat时发生错误所连接矩阵的维数不一致 - How to solve: Error using horzcat Dimensions of matrices being concatenated are not consistent 使用CAT的matlab错误,所连接矩阵的维数不一致 - matlab error using CAT, Dimensions of matrices being concatenated are not consistent 使用带有字符的数组时,要级联的矩阵的维数不一致 - Dimensions of matrices being concatenated are not consistent using array with characters 我的代码运行,有时会出现错误“使用horzcat时出错,所连接的矩阵维数不一致。” - My code runs then sometimes it has error “Error using horzcat Dimensions of matrices being concatenated are not consistent.” 我如何处理“使用vertcat的错误连接矩阵的尺寸在Matlab中不一致”? - How do i handle “Error using vertcat Dimensions of matrices being concatenated are not consistent” in Matlab? bsxfun:所连接矩阵的维数不一致 - bsxfun: Dimensions of matrices being concatenated are not consistent matlab连接的矩阵尺寸不一致 - matlab Dimensions of matrices being concatenated are not consistent Matlab代码崩溃并给出错误:所连接矩阵的维数不一致 - Matlab code crashes and gives error: Dimension of matrices being concatenated are not consistent 在MATLAB中调试错误“被连接的数组的维度不一致” - Debugging the error "Dimensions of arrays being concatenated are not consistent" in MATLAB 在1x6802 double和6802x1 double数据矩阵中,级联矩阵的尺寸不一致 - Dimensions of matrices being concatenated are not consistent in 1x6802 double and 6802x1 double data matrix
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM