Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


phuong
Posts:
20
Registered:
8/23/13


help me. NaR not working
Posted:
Oct 7, 2013 9:16 AM


I used a simple data set for Neural. It's the linear 1:1500. But when I use NaR for this, I don't get exact resulr. Somtime it fits, some times it different target very much. Here's my code:
%% clear;close all;clc; % [X T] = abalone_dataset; T = 1:1500; T = tonndata(T,true,false); %% N = 200; %
% Input and target series are divided in two groups of data: % 1st group: used to train the network
inputSeries = T(1:endN);
% targetSeries = T(1:endN);
% 2nd group: this is the new data used for simulation. inputSeriesVal will % be used for predicting new targets. targetSeriesVal will be used for % network validation after prediction
inputSeriesVal = T(endN+1:end);
%% Network Architecture lag = 2; hidden = 4; delay = 3; net = narnet(lag:delay+lag1,hidden); % view(net); %% Trainning network [Xs,Xi,Ai,Ts] = preparets(net,{},{},inputSeries); net.divideFcn='divideblock'; net.divideParam.trainRatio = 0.85; net.divideParam.valRatio = 0.15; net.divideParam.testRatio = 0; net.trainFcn = 'trainlm'; net = train(net,Xs,Ts,Xi,Ai); %% Predict inputSeriesPred = [inputSeries(enddelaylag+2:end),inputSeriesVal(1:end)]; [Xs,Xi,Ai,Ts] = preparets(net,{},{},inputSeriesPred); yPred = net(Xs,Xi); perf = perform(net,yPred,inputSeriesVal) %% plot(cell2mat(yPred),'r'); hold all; plot( cell2mat(inputSeriesVal),'b'); legend('Predict', 'target');
And here is the one of result when i run code. It create a strange line compare to target line. https://www.dropbox.com/s/6p57eqraqjgf1ry/example2.jpg But this code is right with simplenar_dataset. Please see and help me solve this problem. Thank you very much Phuong.



