标签:
%读取训练数据 [C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16,C17,C17,C19,C20,C21,C22,C23,C24,C25,C26,C27,C28,C29,C30,C31,C32,exp] = textread(‘C:\Users\geek\Desktop\data\testdata.txt‘ , ‘%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f‘,50); n=50; for i=1 :n C15(i)=0; C27(i)=0; C28(i)=0; end %特征值归一化 [input,minI,maxI] = premnmx( [C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,C16,C17,C17,C19,C20,C21,C22,C23,C24,C25,C26,C27,C28,C29,C30,C31,C32 ]‘); %构造输出矩阵 s = length(exp) ; output = zeros( s , 3 ) ; for i = 1 : s output( i , exp( i)+2 ) = 1 ; end %创建神经网络 net = newff( minmax(input) , [5 1] , { ‘logsig‘ ‘purelin‘ } , ‘traingdx‘ ); %设置训练参数 net.trainparam.show = 50 ; net.trainparam.epochs = 1000; net.trainparam.goal = 0.001 ; net.trainParam.lr = 0.001 ; %开始训练 [net,tr,Y,E,Pf,Af] = train( net, input , exp‘ ) ; %读取测试数据 [T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T17,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,ver] = textread(‘C:\Users\geek\Desktop\data\verdata.txt‘ , ‘%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f‘,7); %测试数据归一化 testInput = tramnmx ( [T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T17,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32]‘ , minI, maxI ) ; %仿真 Z = sim( net , testInput ) ; Y E Z
标签:
原文地址:http://www.cnblogs.com/yuanguo/p/4376663.html