欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab神经网络2:数据拟合

发布时间:2025/3/15 循环神经网络 37 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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 Network
Toolbox 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:nnstart
LOAD 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:数据拟合的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。