新版Matlab中神经网络训练函数Newff的使用方法.docx

上传人:b****4 文档编号:4225394 上传时间:2022-11-28 格式:DOCX 页数:6 大小:63.18KB
下载 相关 举报
新版Matlab中神经网络训练函数Newff的使用方法.docx_第1页
第1页 / 共6页
新版Matlab中神经网络训练函数Newff的使用方法.docx_第2页
第2页 / 共6页
新版Matlab中神经网络训练函数Newff的使用方法.docx_第3页
第3页 / 共6页
新版Matlab中神经网络训练函数Newff的使用方法.docx_第4页
第4页 / 共6页
新版Matlab中神经网络训练函数Newff的使用方法.docx_第5页
第5页 / 共6页
点击查看更多>>
下载资源
资源描述

新版Matlab中神经网络训练函数Newff的使用方法.docx

《新版Matlab中神经网络训练函数Newff的使用方法.docx》由会员分享,可在线阅读,更多相关《新版Matlab中神经网络训练函数Newff的使用方法.docx(6页珍藏版)》请在冰豆网上搜索。

新版Matlab中神经网络训练函数Newff的使用方法.docx

新版Matlab中神经网络训练函数Newff的使用方法

新版Matlab中神经网络训练函数Newff的使用方法

一、介绍新版newff

Syntax

net=newff(P,T,[S1S2...S(N-l)],{TF1TF2...TFNl},BTF,BLF,PF,IPF,OPF,DDF)

Description

newff(P,T,[S1S2...S(N-l)],{TF1TF2...TFNl},BTF,BLF,PF,IPF,OPF,DDF)takesseveral

arguments

PRxQ1matrixofQ1sampleR-elementinputvectors

TSNxQ2matrixofQ2sampleSN-elementtargetvectors

Sizeofithlayer,forN-1layers,default=[].Si(OutputlayersizeSNisdeterminedfromT.)

Transferfunctionofithlayer.(Default='tansig'forTFihiddenlayersand'purelin'foroutputlayer.)

BTFBackpropagationnetworktrainingfunction(default='trainlm')

BLFBackpropagationweight/biaslearningfunction(default='learngdm')

IPFRowcellarrayofinputprocessingfunctions.(Default={'fixunknowns','removeconstantrows','mapminmax'})

OPFRowcellarrayofoutputprocessingfunctions.(Default={'removeconstantrows','mapminmax'})

DDFDatadivisonfunction(default='dividerand')

Examples

HereisaproblemconsistingofinputsPandtargetsTtobesolvedwithanetwork.

P=[012345678910];T=[01234321234];

Hereanetworkiscreatedwithonehiddenlayeroffiveneurons.

net=newff(P,T,5);

Thenetworkissimulatedanditsoutputplottedagainstthetargets.

Y=sim(net,P);plot(P,T,P,Y,'o')

Thenetworkistrainedfor50epochs.Againthenetwork'soutputisplotted.

net.trainParam.epochs=50;net=train(net,P,T);Y=sim(net,P);plot(P,T,P,Y,'o')二、新版newff与旧版newff调用语法对比

Example1

比如输入input(6*1000),输出output为(4*1000),那么

旧版定义:

net=newff(minmax(input),[7,1],{'tansig','purelin'},'trainlm');

新版定义:

net=newff(input,output,7,{'tansig','purelin'},'trainlm');Example2

比如输入input(6*1000),输出output为(4*1000),那么

旧版定义:

net=newff(minmax(input),[49,10,1],{'tansig','tansig','tansig'},'traingdx');

新版定义:

net=newff(input,output,[49,10],{'tansig','tansig','tansig'},'traingdx');

regulations,constructionscaffoldingissafeandreliable,andclimbingladders,liftingCommander1established,full-timesafetyofficer1,responsibleforcheckingthesafetyguaranteemeasures,echoedupanddown,preventaccidents.12)trafficpavementinaccordancewithrequirementsofthetransportsector,andseparatedbyclosedisolationbarrier,constructionandnon-constructionwithbarrierisolation.13)volunteerfireorganizations,employeesconductingfirepreventionpublicityandeducationoftheknowledge,skills,andorganizationalimplementationoffire-fightingandemergencyevacuationplansandwalkthroughs.8.4.5specificconstructionprogramforsafetytechnologyaccordingtotheHebeiprovincialconstructionsafetyinspectionrulesfortheimplementationofrequirementsofthestandard,aseparatespecificconstructionprogramforthefollowing1)scaffolderection,dismantlingprogramme;2)Foundationsupportschemes;3)constructionprojectoftemplateengineering;4)"threetreasures","four"protectionscheme;5)constructionorganizationdesignoftemporarypowersupply;6)installation,demolitionofatowercraneprogramme;7)liftingoperationplan.8.58.5.1environmentalmanagementgoalsofenvironmentalprotection,civilizationconstructionwithoutmajorenvironmentalpollutionaccident,wastegas,wastewater,noise,dust,solid

三、旧版newff使用方法在新版本中使用

提示:

旧版本定义的newff虽也能在新版本中使用,但会有警告,警告如下:

Warning:

NEWFFusedinanobsoleteway.>Inobs_useat18

Innewff>create_networkat127

Innewffat102

SeehelpforNEWFFtoupdatecallstothenewargumentlist.

四、新版newff与旧版newff使用的训练效果对比

旧版本:

旧用法训练次数多,但精度高

新版本:

新用法训练次数少,但精度可能达不到要求

造成上述原因是:

程序里面的权值、阈值的初始值是随机赋值的,所以每次运行的结果都会不一样,

有好有坏。

你可以把预测效果不错的网络的权值和阈值作为初始值。

具体可以查看net.iw{1,1}、net.lw{2,1}、net.b{1}、net.b{2}的值。

regulations,constructionscaffoldingissafeandreliable,andclimbingladders,liftingCommander1established,full-timesafetyofficer1,responsibleforcheckingthesafetyguaranteemeasures,echoedupanddown,preventaccidents.12)trafficpavementinaccordancewithrequirementsofthetransportsector,andseparatedbyclosedisolationbarrier,constructionandnon-constructionwithbarrierisolation.13)volunteerfireorganizations,employeesconductingfirepreventionpublicityandeducationoftheknowledge,skills,andorganizationalimplementationoffire-fightingandemergencyevacuationplansandwalkthroughs.8.4.5specificconstructionprogramforsafetytechnologyaccordingtotheHebeiprovincialconstructionsafetyinspectionrulesfortheimplementationofrequirementsofthestandard,aseparatespecificconstructionprogramforthefollowing1)scaffolderection,dismantlingprogramme;2)Foundationsupportschemes;3)constructionprojectoftemplateengineering;4)"threetreasures","four"protectionscheme;5)constructionorganizationdesignoftemporarypowersupply;6)installation,demolitionofatowercraneprogramme;7)liftingoperationplan.8.58.5.1environmentalmanagementgoalsofenvironmentalprotection,civilizationconstructionwithoutmajorenvironmentalpollutionaccident,wastegas,wastewater,noise,dust,solid

现在给一个完整的例子

%%清空环境变量

clc

clear

%%训练数据预测数据

data=importdata('test.txt');

%从1到768间随机排序

k=rand(1,768);

[m,n]=sort(k);

%输入输出数据

input=data(:

1:

8);

output=data(:

9);

%随机提取500个样本为训练样本,268个样本为预测样本input_train=input(n(1:

500),:

)';output_train=output(n(1:

500),:

)';input_test=input(n(501:

768),:

)';output_test=output(n(501:

768),:

)';

%输入数据归一化

[inputn,inputps]=mapminmax(input_train);

%%BP网络训练

%%初始化网络结构

net=newff(inputn,output_train,10);

net.trainParam.epochs=1000;

net.trainParam.lr=0.1;

net.trainParam.goal=0.0000004;

%%网络训练

net=train(net,inputn,output_train);

%%BP网络预测

%预测数据归一化

inputn_test=mapminmax('apply',input_test,inputps);

%网络预测输出

BPoutput=sim(net,inputn_test);

%%结果分析

regulations,constructionscaffoldingissafeandreliable,andclimbingladders,liftingCommander1established,full-timesafetyofficer1,responsibleforcheckingthesafetyguaranteemeasures,echoedupanddown,preventaccidents.12)trafficpavementinaccordancewithrequirementsofthetransportsector,andseparatedbyclosedisolationbarrier,constructionandnon-constructionwithbarrierisolation.13)volunteerfireorganizations,employeesconductingfirepreventionpublicityandeducationoftheknowledge,skills,andorganizationalimplementationoffire-fightingandemergencyevacuationplansandwalkthroughs.8.4.5specificconstructionprogramforsafetytechnologyaccordingtotheHebeiprovincialconstructionsafetyinspectionrulesfortheimplementationofrequirementsofthestandard,aseparatespecificconstructionprogramforthefollowing1)scaffolderection,dismantlingprogramme;2)Foundationsupportschemes;3)constructionprojectoftemplateengineering;4)"threetreasures","four"protectionscheme;5)constructionorganizationdesignoftemporarypowersupply;6)installation,demolitionofatowercraneprogramme;7)liftingoperationplan.8.58.5.1environmentalmanagementgoalsofenvironmentalprotection,civilizationconstructionwithoutmajorenvironmentalpollutionaccident,wastegas,wastewater,noise,dust,solid

%根据网络输出找出数据属于哪类

BPoutput(find(BPoutput<0.5))=0;BPoutput(find(BPoutput>=0.5))=1;

%%结果分析

%画出预测种类和实际种类的分类图

figure

(1)

plot(BPoutput,'og')

holdon

plot(output_test,'r*');

legend('预测类别','输出类别')

title('BP网络预测分类与实际类别比对','fontsize',12)ylabel('类别标签','fontsize',12)

xlabel('样本数目','fontsize',12)

ylim([-0.51.5])

%预测正确率

rightnumber=0;

fori=1:

size(output_test,2)

ifBPoutput(i)==output_test(i)

rightnumber=rightnumber+1;

end

end

rightratio=rightnumber/size(output_test,2)*100;

sprintf('测试准确率=%0.2f',rightratio)

regulations,constructionscaffoldingissafeandreliable,andclimbingladders,liftingCommander1established,full-timesafetyofficer1,responsibleforcheckingthesafetyguaranteemeasures,echoedupanddown,preventaccidents.12)trafficpavementinaccordancewithrequirementsofthetransportsector,andseparatedbyclosedisolationbarrier,constructionandnon-constructionwithbarrierisolation.13)volunteerfireorganizations,employeesconductingfirepreventionpublicityandeducationoftheknowledge,skills,andorganizationalimplementationoffire-fightingandemergencyevacuationplansandwalkthroughs.8.4.5specificconstructionprogramforsafetytechnologyaccordingtotheHebeiprovincialconstructionsafetyinspectionrulesfortheimplementationofrequirementsofthestandard,aseparatespecificconstructionprogramforthefollowing1)scaffolderection,dismantlingprogramme;2)Foundationsupportschemes;3)constructionprojectoftemplateengineering;4)"threetreasures","four"protectionscheme;5)constructionorganizationdesignoftemporarypowersupply;6)installation,demolitionofatowercraneprogramme;7)liftingoperationplan.8.58.5.1environmentalmanagementgoalsofenvironmentalprotection,civilizationconstructionwithoutmajorenvironmentalpollutionaccident,wastegas,wastewater,noise,dust,solid

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1