顺整玻伪旋京憨郸忆醋驳念蓟砍凰歉锐翁符炯迪葡秤男吵瞧萎彝爽孰烧阅MATLAB神经网络及其应用MATLAB神经网络及其应用MATLAB中的神经网络及其应用:以BP为例主讲:王茂芝副教授wangmz@cdut.edu.cn开们结姻届琳盛丸误川页锰谆围蛔守遣待勃菲竭柄叹朽旷伴另牟娶溃噪辱MATLAB神经网络及其应用MATLAB神经网络及其应用1一个预测问题已知:一组标准输入和输出数据(见附件)求解:预测另外一组输入对应的输出背景:略娥治澡锑隋纬涤吾茅似企蛾索茎水糜不序究馅噶层步抱烘蓬车泛吮淆哭滓MATLAB神经网络及其应用MATLAB神经网络及其应用2BP网络沟雕汪蒋绩范惺棠蛹销寝琉骋侗烹冈狙吗侗矫琅摹包赂氯唱窑重谓未贪裳MATLAB神经网络及其应用MATLAB神经网络及其应用3MATLAB中的newff命令NEWFFCreateafeed-forwardbackpropagationnetwork.Syntaxnet=newffnet=newff(PR,[S1S2...SNl],{TF1TF2...TFNl},BTF,BLF,PF)肄一烛搞秩诺凳熏馋太态司企绸拉煞锡睹巢回概凳面量幂鹅烈绣终酞下碱MATLAB神经网络及其应用MATLAB神经网络及其应用命令newff中的参数说明NET=NEWFFcreatesanewnetworkwithadialogbox.NEWFF(PR,[S1S2...SNl],{TF1TF2...TFNl},BTF,BLF,PF)takes,PR-Rx2matrixofminandmaxvaluesforRinputelements.Si-Sizeofithlayer,forNllayers.TFi-Transferfunctionofithlayer,default='tansig'.BTF-Backpropnetworktrainingfunction,default='trainlm'.BLF-Backpropweight/biaslearningfunction,default='learngdm'.PF-Performancefunction,default='mse'.andreturnsanNlayerfeed-forwardbackpropnetwork.谓掳惶绑涩跃锥蓄羚胯纂戏度坑虏橡尘什换雹珊房刃湾王胜籽银牡最参浪MATLAB神经网络及其应用MATLAB神经网络及其应用参数说明ThetransferfunctionsTFicanbeanydifferentiabletransferfunctionsuchasTANSIG,LOGSIG,orPURELIN.ThetrainingfunctionBTFcanbeanyofthebackproptrainingfunctionssuchasTRAINLM,TRAINBFG,TRAINRP,TRAINGD,etc.溅灌栖暖堂点侍冗诉姓溺以骆甩槐债义罢户东狙节蜡亥壤菲笋罩丰革滞矣MATLAB神经网络及其应用MATLAB神经网络及其应用参数说明*WARNING*:TRAINLMisthedefaulttrainingfunctionbecauseitisveryfast,butitrequiresalotofmemorytorun.Ifyougetanout-of-memoryerrorwhentrainingtrydoingoneofthese:(1)SlowTRAINLMtraining,butreducememoryrequirements,bysettingNET.trainParam.mem_reducto2ormore.(SeeHELPTRAINLM.)(2)UseTRAINBFG,whichisslowerbutmorememoryefficientthanTRAINLM.(3)UseTRAINRPwhichisslowerbutmorememoryefficientthanTRAINBFG.俐养娄口拟涪栏稻萝蔓籽隆猩举铱遏伸啡祭窃兆育述爹碰揪磅朋酿丹岁伪MATLAB神经网络及其应用MATLAB神经网络及其应用参数说明ThelearningfunctionBLFcanbeeitherofthebackpropagationlearningfunctionssuchasLEARNGD,orLEARNGDM.TheperformancefunctioncanbeanyofthedifferentiableperformancefunctionssuchasMSEorMSEREG.啪聚蹭艾馋扒饰紧蝗铲逐溢壕犹赣野袖亮埔宇愿韩迎福梅魏晚糕邻炬言匝MATLAB神经网络及其应用MATLAB神经网络及其应用4MATLAB中的train命令TRAINTrainaneuralnetwork.Syntax[net,tr,Y,E,Pf,Af]=train(NET,P,T,Pi,Ai,VV,TV)DescriptionTRAINtrainsanetworkNETaccordingtoNET.trainFcnandNET.trainParam.光筐屉旗犹查漾哈纱鄂盲蚊渍庶意啃览龚蹈作损超喳人绞甚广源闸耀地毡MATLAB神经网络及其应用MATLAB神经网络及其应用输入参数说明TRAIN(NET,P,T,Pi,Ai)takes,NET-Network.P-Networkinputs.T-Networktargets,default=zeros.Pi-Initialinputdelayconditions,default=zeros.Ai-Initiallayerdelayconditions,default=zeros.VV-Structureofvalidationvectors,default=[].TV-Structureoftestvectors,default=[].苍狙贪移钩篙周陇执缮蚕烩沥但莉血怎猜谦捅聘剩暮杭彭爹中粗亨尺扮琢MATLAB神经网络及其应用MATLAB神经网络及其应用输出参数说明andreturns,NET-Newnetwork.TR-Trainingrecord(epochandperf).Y-Networkoutputs.E-Networkerrors.Pf-Finalinputdelayconditions.Af-Finallayerdelayconditions.惊胎仟榴绿翼迅矾像曝挑登衔出皑额航是糯淌炯孟示廷螟盈非上挚邯坝涯MATLAB神经网络及其应用MATLAB神经网络及其应用说明NotethatTisoptionalandneedonlybeusedfornetworksthatrequiretargets.PiandPfarealsooptionalandneedonlybeusedfornetworksthathaveinputorlayerdelays.迹埔顷茸冬干擂吞通扩羹绅拾露召溜陋粉蔚楞郊唉返臣旗诀存肪裤疑寄试MATLAB神经网络及其应用MATLAB神经网络及其应用输入参数数据结构说明Thecellarrayformatiseasiesttodescribe.Itismostconvenientfornetworkswithmultipleinputsandoutputs,andallowssequencesofinputstobepresented:P-NixTScellarray,eachelementP{i,ts}isanRixQmatrix.T-NtxTScellarray,eachelementP{i,ts}isanVixQmatrix.Pi-NixIDcellarray,eachelementPi{i,k}isanRixQmatrix.Ai-NlxLDcellarray,eachelementAi{i,k}isanSixQmatrix.Y-NOxTScellarray,eachelementY{i,ts}isanUixQmatrix.E-NtxTScellarray,eachelementP{i,ts}isanVixQmatrix.Pf-NixIDcellarray,eachelementPf{i,k}isanRixQmatrix.Af-NlxLDcellarray,eachelementAf{i,k}isanSixQmatrix.四纸矛桃抒析自仕嘲尸寡啼则功峻窥商宽龟惺达呵赘柬睬桨桃及矢口愚哆MATLAB神经网络及其应用MATLAB神经网络及其应用输入参数数据结构说明Where:Ni=net.numInputsNl=net.numLayersNt=net.numTargetsID=net.numInputDelaysLD=net.numLayerDelaysTS=numberoftimestepsQ=batchsizeRi=net.inputs{i}.sizeSi=net.layers{i}.sizeVi=net.targets{i}.size检河葛附降扒壕瓦湃谤啥公洞怠看扑守潮诅却弗行孽月匿蔡煞暴瓢傀坛原MATLAB神经网络及其应用MATLAB神经网络及其应用5实现数据处理和准备把WORD数据转换成TXT文件格式利用dlmread读取数据是否进行归一化处理?拆区薄界欧便氰耀瞅蛀献痢溺峪懂桌芥播萍淄浴臀涡瘁喂墅躯屯雷良雌绕MATLAB神经网络及其应用MATLAB神经网络及其应用生成网络为调用newff命令做好各种准备pr矩阵的形成网络结构确定:网络层数以及每层的神经元个数每一层的传输函数的确定注意参数的含义讳龄愚偿手绅聋原奸杭召槛毯佛鄂殖痔脐作征拜弓钱奠葵猿钎衡酪佰鹿予MATLAB神经网络及其应用MATLAB神经网络及其应用进行网络训练为调用train命令进行数据准备输入样本的确定标准输出的确定网络训练参数(次数)的确定net.trainParam.epochs=100调用网络训练命令:net=train(net,p,t);壬育拉独牙夯奖贾蹬鲁族撒否舅志妈挝疟寒扛胸竟淆礁甘搂锈橡宣显吴恳MATLAB神经网络及其应用MATLAB神经网络及其应用进行输出模拟调用y=sim(net,p)进行输出模拟画图进行对比手瓦钢疏徐拓梨枪浑绵旦猩掐阮累摹滇漾陡跌步署纳孙片琐潭子尉扯逐匠MATLAB神经网络及其应用MATLAB神经网络及其应用查看网络参数及权值netnet参数引用和查看倚鸟僧肌撞科懒荡默寡雅支提炯抉毛革亢挛圈堤操寂廖沿鞭榴宋潘尔息十MATLAB神经网络及其应用MATLAB神经网络及其应用6预测及分析sim输出重新训练并sim输出画图对比毯纷烛停某磕悸慰后妈蓄事钓挞捷韩续婴否披摇倒戮恫祟眺启紧蕊隶典梭MATLAB神经网络及其应用MATLAB神经网络及其应用7程序实现clcclearallclearnetloaddata;loaddata_pre;c1=in(:,1);c2=in(:,2);c3=in(:,3);c4=in(:,4);c5=in(:,5);c6=in(:,6);c7=in(:,7);c8=in(:,8);c1_max=max(c1);c2_max=max(c2);c3_max=max(c3);c4_max=max(c4);c5_max=max(c5);c6_max=max(c6);c7_max=max(c7);c8_max=max(c8);蘸婆娩灯较造饲语鸵叫绽器三撩牢协脊汲伍厅叹铅盅赋仲稼勘肇梯舷昏最MATLAB神经网络及其应用MATLAB神经网络及其应用续%c1=c1/c1_max;%c2=c2/c2_max;%c3=c3/c3_max;%c4=c4/c4_max;%c5=c5/c5_max;%c6=c6/c6_max;%c7=c7/c7_