首先一個很簡單的例子:
1 - 首先,你需要爲數據輸入輸出數據矩陣和其他。 這裏我正在使用來自matlab的預設數據。你應該儘量讓你的輸入輸出數據的結構是這樣的:
[InData,TarData] = engin_dataset;
所以在這裏我們有兩個輸入和兩個輸出(MIMO)2 - > 2 2 - 現在你應該創建網絡。我所選擇的前饋網絡:
net1 = newff(minmax(InData),[10,2],{'tansig','purelin'},'trainlm')
這裏我已經定義了輸入數據範圍,數量的神經元中的每個層(包括輸出層= 2),功能類型和訓練算法的類型。
3-現在,你可以訓練你的網絡:
net2 = train(net1,InData,TarData)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%
和這裏的代碼來了,從利用MATLAB自動生成一個例子:
% load data
[inputs,targets] = engin_dataset;
%inputs = engineInputs;
%targets = engineTargets;
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
% View the Network
view(net)
來源
2013-04-19 12:56:58
NKN
檢查的問題/答案是:http:/ /stackoverflow.com/questions/1672850/how-to-set-output-size-in-matlab-newff-method – NKN