0

nprtoolを使用して、また手動で、newprメソッドとtrainメソッドを呼び出して、ニューラルネットワークをトレーニングしようとしています。デフォルトの列ではなく、行として方向付けられたサンプルを使用します

nprtool

nprtoolを使用しても問題はありませんが、自動生成されたMファイルを呼び出すと、出力は次のようになります。

??? Error using ==> network.train at 145
Targets are incorrectly sized for network.
Matrix must have 24 columns.

Error in ==> create_pr_net at 29
[net,tr] = train(net,inputs,targets);

私の入力は140x24で、ターゲットは140x3です。

Matlabによって生成されたコードは次のとおりです。

function net = create_pr_net(inputs,targets)
%CREATE_PR_NET Creates and trains a pattern recognition neural network.
%
%  NET = CREATE_PR_NET(INPUTS,TARGETS) takes these arguments:
%    INPUTS - RxQ matrix of Q R-element input samples
%    TARGETS - SxQ matrix of Q S-element associated target samples, where
%      each column contains a single 1, with all other elements set to 0.
%  and returns these results:
%    NET - The trained neural network
%
%  For example, to solve the Iris dataset problem with this function:
%
%    load iris_dataset
%    net = create_pr_net(irisInputs,irisTargets);
%    irisOutputs = sim(net,irisInputs);
%
%  To reproduce the results you obtained in NPRTOOL:
%
%    net = create_pr_net(inputs,targets);

% Create Network
numHiddenNeurons = 2000;  % Adjust as desired
net = newpr(inputs,targets,numHiddenNeurons);
net.divideParam.trainRatio = 90/100;  % Adjust as desired
net.divideParam.valRatio = 5/100;  % Adjust as desired
net.divideParam.testRatio = 5/100;  % Adjust as desired

% Train and Apply Network
[net,tr] = train(net,inputs,targets);
outputs = sim(net,inputs);

% Plot
plotperf(tr)
plotconfusion(targets,outputs)

MatlabR2010aを使用しています。

ありがとう。

4

1 に答える 1

3

Matlabヘルプファイルに記載されているように:

入力-QのRxQ行列R要素の入力サンプルターゲット-QS要素に関連付けられたターゲットサンプルのSxQ行列

Matlabトレイン関数を手動で呼び出す前に、入力行列とターゲット行列の転置が必要になる可能性があります。

Input = Input';Taget = Target';

于 2012-12-17T03:31:50.893 に答える