matlab神经网络2:数据拟合
生活随笔
收集整理的這篇文章主要介紹了
matlab神经网络2:数据拟合
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.前文
? ? The following topics explain how to use graphical tools for training neural networks to solve problems in function fitting, pattern recognition, clustering, and time series. Using these tools can give us an excellent introduction to the use of the Neural NetworkToolbox software:
? “Fit Data with a Shallow Neural Network”?
? “Classify Patterns with a Shallow Neural Network”?
? “Cluster Data with a Self-Organizing Map”?
? “Shallow Neural Network Time-Series Prediction and Modeling”?
2.淺層神經網絡進行數據擬合
2.1 GUI的方法
command-line:nnstartLOAD chemical_dataset.MAT loads these two variables:
chemicalInputs - a 8x498 matrix defining measurements taken from eight sensors during a chemical process.
chemicalTargets - a 1x498 matrix of a ninth sensor's measurements, to be estimated from the first eight.
A good estimator for the ninth sensor will allow it to be removed and estimations used in its place.
[X,T] = chemical_dataset loads the inputs and targets into variables of your own choosing. ? ??
Select a training algorithm, then click Train. Levenberg-Marquardt (trainlm) is recommended for most problems, but for some noisy and small problems Bayesian Regularization (trainbr) can take longer but obtain a better solution. For large problems, however, Scaled Conjugate Gradient (trainscg) is recommended as it uses gradient calculations which are more memory efficient than the Jacobian calculations the other two algorithms use. This example uses the default LevenbergMarquardt.
The regression plots display the network outputs with respect to targets for training, validation, and test sets. For a perfect fit, the data should fall along a 45 degree line, where the network outputs are equal to the targets. For this problem, the fit is reasonably good for all data sets, with R values in each case of 0.93 or above. If even more accurate results were required, you could retrain the network by clicking Retrain in nftool. This will change the initial weights and biases of the network, and may produce an improved network after retraining. Other options are provided on the following
The histogram can give you an indication of
outliers, which are data points where the fit is significantly worse than the majority of data.?
如果訓練集誤差比較大,應該是網絡太小了,增加層數或者每層的神經元數; 如果測試集的誤差比較大,應該就是過擬合。
利用工具箱生成自動生成代碼:
2.2 代碼驅動
% Solve an Input-Output Fitting problem with a Neural Network % Script generated by NFTOOL % houseInputs - input data. % houseTargets - target data. inputs = houseInputs; targets = houseTargets; % Create a Fitting Network hiddenLayerSize = 10; net = fitnet(hiddenLayerSize); % Set up 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(outputs,targets); performance = perform(net,targets,outputs); % View the Network view(net) % Plots % Uncomment these lines to enable various plots. figure, plotperform(tr) figure, plottrainstate(tr) %figure, plotfit(targets,outputs) figure, plotregression(targets,outputs) figure, ploterrhist(errors)總結
以上是生活随笔為你收集整理的matlab神经网络2:数据拟合的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 创建自定义的Visual Studio项
- 下一篇: How To Set Up a TCP/