资源简介
BP神经网络源代码,压缩包里面包括训练代码、测试代码、采样数据。

代码片段和文件信息
close all
clear all
clc
web -browser http://www.ilovematlab.cn/thread-220251-1-1.html
x=xlsread(‘training_data.xls‘[‘B2:G401‘]);
y=xlsread(‘training_data.xls‘[‘I2:K401‘]);
inputs = x‘;
targets = y‘;
% 创建一个模式识别网络(两层BP网络),同时给出中间层神经元的个数,这里使用20
hiddenlayerSize = 20;
net = patternnet(hiddenlayerSize);
% 对数据进行预处理,这里使用了归一化函数(一般不用修改)
% For a list of all processing functions type: help nnprocess
net.inputs{1}.processFcns = {‘removeconstantrows‘‘mapminmax‘};
net.outputs{2}.processFcns = {‘removeconstantrows‘‘mapminmax‘};
% 把训练数据分成三部分,训练网络、验证网络、测试网络
% For a list of all data division functions type: help nndivide
net.divideFcn = ‘dividerand‘; % Divide data randomly
net.divideMode = ‘sample‘; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% 训练函数
% For a list of all training functions type: help nntrain
net.trainFcn = ‘trainlm‘; % Levenberg-Marquardt
% 使用均方误差来评估网络
% For a list of all performance functions type: help nnperformance
net.performFcn = ‘mse‘; % Mean squared error
% 画图函数
% For a list of all plot functions type: help nnplot
net.plotFcns = {‘plotperform‘‘plottrainstate‘‘ploterrhist‘ ...
‘plotregression‘ ‘plotfit‘};
% 开始训练网络(包含了训练和验证的过程)
[nettr] = train(netinputstargets);
% 测试网络
outputs = net(inputs);
errors = gsubtract(targetsoutputs);
performance = perform(nettargetsoutputs)
% 获得训练、验证和测试的结果
trainTargets = targets .* tr.trainMask{1};
valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(nettrainTargetsoutputs)
valPerformance = perform(netvalTargetsoutputs)
testPerformance = perform(nettestTargetsoutputs)
% 可以查看网络的各个参数
view(net)
% 根据画图的结果,决定是否满意
% Uncomment these lines to enable various plots.
figure plotperform(tr)
figure plottrainstate(tr)
figure plotconfusion(targetsoutputs)
figure ploterrhist(errors)
%如果你对该次训练满意,可以保存训练好网络
save(‘training_net.mat‘‘net‘‘tr‘);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-03-22 20:35 BP\
文件 30369 2013-03-22 19:14 BP\training_data.xls
文件 2238 2013-03-22 19:09 BP\Training_NPR.m
文件 600 2013-03-22 19:10 BP\Use_For_Predict.m
- 上一篇:多重曝光图像的区域融合
- 下一篇:非常有用的自适应信号处理答案
相关资源
- 随机森林R语言代码
- 计算机图形学 边填充算法实现代码
- 直流无刷电机方波驱动 stm32 例程代码
- 仿知乎界面小程序源代码
- 贪吃蛇源代码.fla
- 周立功开发板ProASIC3实验-syn_FIFO代码
- IMX385驱动代码.zip
- dotnet 写字板 实验 源代码 不好请要不
- 图像二维小波变换的实现源代码
- 八三编码器设计 VHDL代码 简单,包附
- linux应用层的华容道游戏源代码
- 交通咨询模拟系统完整代码
- http请求状态代码
- 数值分析所有实验代码
- 网上拍卖系统完整源代码
- 音乐代码转换软件 单片机编程时用
- CSMA/CD等动画演示加源代码
- silicon lab公司的收音IC SI47XX全套开发工
- 用51单片机实现G代码翻译
- 合同管理系统的源代码(附数据库)
- 用VC 编写的仿QQ聊天室程序源代码
- web班级网站设计代码
- 38k单片机红外发送代码、keil
- STM32F103 串口程序(完整版)
- 网络唤醒代码
- VPC3_DPV1源代码,Profibus
- PB做的托盘程序(最小化后在左下角显
- RSA算法源码
- ubuntu9.10 可加载内核模块和字符设备驱
- 操作系统 LRU算法 实验报告 及 程序代
评论
共有 条评论