matlab中关于错误使用 network/train (line 340) Output data size does not match net.outputs{2}.size.

% 将第一类的29-264,第二类的294-546,第三类的576-699做为训练集
P_train = [breast_cancer_wisconsin(29:264,2:10);breast_cancer_wisconsin(294:546,2:10);breast_cancer_wisconsin(576:699,2:10)]';
% 相应的训练集的标签也要分离出来
Tc_train = [breast_cancer_wisconsin_class(29:264);breast_cancer_wisconsin_class(294:546);breast_cancer_wisconsin_class(576:699)]';
% 将第一类的1-28,第二类的265-293,第三类的547-575做为测试集
P_test = [breast_cancer_wisconsin(1:28,2:10);breast_cancer_wisconsin(265:293,2:10);breast_cancer_wisconsin(547:575,2:10)]';
% 相应的测试集的标签也要分离出来
Tc_test = [breast_cancer_wisconsin_class(1:28);breast_cancer_wisconsin_class(265:293);breast_cancer_wisconsin_class(547:575)]';

% 训练数据
% P_train = Train(:,3:end)';
% Tc_train = Train(:,2)';
T_train = ind2vec(Tc_train);
% 测试数据
% P_test = Test(:,3:end)';
% Tc_test = Test(:,2)';

%% 创建网络
count_B = length(find(Tc_train == 4));
count_M = length(find(Tc_train == 2));
%rate_B = count_B/500;
%rate_M = count_M/500;
rate_B = count_B/613;
rate_M = count_M/613;
net = newlvq(minmax(P_train),20,[rate_B rate_M],0.01,'learnlv1');
% 设置网络参数
net.trainParam.epochs = 1000;%设置训练训练次数
net.trainParam.show = 10;%设置数据显示刷新频率,学习次刷新一次图象
%net.trainParam.lr = 0.1; % 学习速率,这里设置为0.1
net.trainParam.lr = 0.1; % 学习速率,这里设置为0.01
net.trainParam.goal = 0.1;% 训练目标最小误差,这里设置为0.1

%% 训练网络
net = train(net,P_train,T_train);

%% 仿真测试
T_sim = sim(net,P_test);
Tc_sim = vec2ind(T_sim);
result = [Tc_sim;Tc_test]
在运行到net = train(net,P_train,T_train);时报>> net = train(net,P_train,T_train);
错误使用 network/train (line 340)
Output data size does not match net.outputs{2}.size.这个错误,上面是程序。求大神解答

上面显示的错误是你训练数据集和你net模型的输出数据集不匹配。可以检查一下你的训练数据的的维度和net模型的维度是否一致
温馨提示:内容为网友见解,仅供参考
无其他回答

...network\/train (line 340) Output data size does not match net.o...
上面显示的错误是你训练数据集和你net模型的输出数据集不匹配。可以检查一下你的训练数据的的维度和net模型的维度是否一致

...非线性拟合过程中出错 Input data size does not match net.inputs{...
pr(1:16,1)=0; %输入矢量的取值范围矩阵 pr(1:16,2)=1;bpnet=newff(pr,[12 1],{'tansig', 'tansig'},'traingdx', 'learngdm');--- 如果你有n个变量,pr就是一个n行2列的矩阵,第i行代表第i个输入变量的范围(range),按楼主的写法,有16个输入变量了.楼主的输入变量应该是两个,所以...

matlab 错误怎么改Output argument "c" (and maybe others) not assign...
比如说,如果调用时刚好满足(b-a)\/2<=0.5*tol,那么循环体里面的代码就不会执行,c也就不会被赋值,相应就会出现题主说的错误。

bp神经网络人口预测程序(matlab实现)
plotperform(tr) %误差下降线%% 下面预测往后预测几个时间段fn=7; %预测步数为fn。f_in=iinput(n-lag+1:end)';f_out=zeros(1,fn); %预测输出% 多步预测时,用下面的循环将网络输出重新输入for i=1:fn f_out(i)=net(f_in); f_in=[f_in(2:end);f_out(i)];end% ...

请问一直提示“错误使用 fmincon (line 213) FMINCON requires at least...
1、函数fmincon的输入参数至少要有4个,即 x = fmincon(fun,x0,A,b)你现在遇到的报错就是这个原因。在有非线性约束的情况下,基本调用格式为 x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)至于那些线性等式约束、不等式约束以及参数上下限约束,如果不存在,要用空数组占位,而不是想当然地...

matlab:Error using fun (line 22) Not enough input arguments._百度知...
警告:Not enough input arguments。其意思为输入参数不足。问题出在这个语句上, Beq=[1,R].'; 缺 R 的数值。这里R是个具体的数据,而不能是一个变量。

在matlab中调用函数时显示 Output argument "X_yun" (and maybe others...
有时候是因为函数里面设置的条件不满足,所以这个参数没有在函数中被赋值。也就说这个参数没有赋初值,也没有在函数里面后面的语句中赋值。因此,写函数的时候一定要保证无论在哪一个条件语句中,都要有相应的赋值语句,才能保证该参数一定有值返回。

在matlab2015中调用sim()函数出错
[normTrainOutput, Xf, Af] = sim(net, trainSamples.P, [], [], trainSamples.T);[normValidateOutput, Xf, Af] = sim(net, validateSamples.P, [], [], validateSamples.T);[normTestOutput,Xf,Af] = sim(net, testSamples.P, [], [], testSamples.T);换成这个 ...

MATLAB中读取示波器波形时警告:The EOI line was asserted before SIZ...
data = fread(v, 30);char(data)'Warning: The EOI line was asserted or the EOSCharCode was detected before SIZE values were available.ans = 9.9E data = fread(v, 30);char(data)'Warning: The EOI line was asserted or the EOSCharCode was detected before SIZE values were ...

求高手指导matlab fmincon函数 Not enough input arguments.
stepsize: 0.0294 algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'firstorderopt: 223.6754 constrviolation: 16.1374 message: [1x145 char]不过会出现下面的提示:Warning: Trust-region-reflective algorithm does not solve this type of problem, using active-set algorithm. You ...

相似回答