www.pudn.com > Kdd-DT-NN.rar > NN_training.m, change:2016-01-31,size:1167b


function net = NN_training(trainX,trainY,m) 
%trainX: d*N input vector where N denotes the number of the training data 
%and d shows the dimensionality of the feature vector 
 
%trainY: C*N output vector 
 
%m: number of hidden units 
 
%----------------------------------------------------------------- 
rand('seed',0) % Initialization of the random number generators 
randn('seed',0) % for reproducibility of net initial conditions 
 
% Neural network definition 
net = newff(trainX,trainY,[m],{'tansig','tansig'},'traingdx'); 
 
% Neural network initialization 
 
 
 
 
%---------------------------------------------------------------- 
net = init(net); 
 
%----------------------------- 
net.trainFcn = 'trainscg'; 
net.trainParam.lr = .4; 
net.trainParam.epochs = 100000; 
net.trainParam.show = 10; 
net.trainParam.Performance=0.283; 
%net.trainParam.goal = 1e-3; 
net.trainParam.goal = .00100; 
%----------------------------- 
 
% Setting parameters 
%net.trainParam.epochs = 1000;  
%net.trainParam.lr = 1; % learning rate  
%net.trainParam.goal = 1e-5; % stop if the cost function drops below the specified value  
%training 
net = train(net,trainX,trainY);