为什么不能在脚本中使用任何一种方法?
将问题的不同部分组合成如下脚本在 2015b 中运行时不会出现错误...
mynet=patternnet([]);
% Edit mynet before training it
mynet.divideParam.trainRatio = 1;
mynet.divideParam.valRatio = 0;
mynet.divideParam.testRatio = 0;
P=rand(10,1000);
T=rand(2,1000);
[mynet,tr]=train(mynet,P,T);
编辑:
您的困难可能是使用 2012b 语法的细微变化,因此最好参考旧文档:
https://uk.mathworks.com/help/releases/R2012b/nnet/ref/patternnet.html
您似乎想使用dividetrain,它将为您的数据分配索引,完全用于训练。
[trainInd,valInd,testInd] = dividetrain(Q,trainRatio,valRatio,testRatio) 将所有目标分配给训练集,没有目标分配给验证集或测试集。
Inputs:
Q = Number of targets to divide up.
Ratios = ratios of each data use type
Outputs:
trainInd = Training indices equal to 1:Q
valInd = Empty validation indices, []
testInd = Empty test indices, []
在您的情况下,您可以手动创建它,但值得知道这些函数存在,例如,如果您想要特定的比率,请使用 divideint。
然后尝试使用
P=rand(10,1000);
T=rand(2,1000);
mynet=patternnet([]);
% Edit mynet before training it
mynet.divideParam.trainInd = trainInd; % 1:size(P,1)
mynet.divideParam.valInd = valInd; % []
mynet.divideParam.testInd = testInd; % []
[mynet,tr]=train(mynet,P,T);
注意:我没有 2012b,因此无法为您完全测试。