Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: help me predict Mackey glass by neural
Replies: 3   Last Post: Oct 1, 2013 6:06 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
phuong

Posts: 20
Registered: 8/23/13
help me predict Mackey glass by neural
Posted: Sep 30, 2013 4:53 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi everyone,
I want to use feedforward to predict mackey-glss time series. But when I set delay =10, hidden from 1:10. It train very good but:
1. when I apply to multi-step, some time it fits a little, somtime it not fit any thing.
2. I used double loop like prof Greg with delay = 10 and give the result: hmax =9, with hiddenmax =9 and with all hidden I same receive R>0.9 with 20/20 trial. But when apply to my code, R< 0.09 for train,valid and test. I sets divideblock but not improve R.

Here is my code:

%% Input
clc;clear;close all;
load mgdata.dat
a = mgdata;
time = a(:, 1);
x_t = a(:, 2);
plot(time, x_t);
xlabel('Time (sec)','fontsize',10); ylabel('x(t)','fontsize',10);
title('Mackey-Glass Chaotic Time Series','fontsize',10);
%% parameter
% lag = 1;
% delay = 10;
% hidden = 10;
% net = timedelaynet(lag:lag+delay,hidden)
% net.divideFcn = '';
% net.performFcn = 'msereg';
% net.performParam.ratio = 0.5;
% net.trainParam.show = 5;
% % net.trainParam.epochs = 500;
% net.trainParam.goal = 1e-5;
% net.trainFcn = 'trainscg'
% net = train(net,x_t,x_t);

%% 2.Preparation data
N = 500;
input = tonndata(x_t,false,false);
output = input;
% Divide to two group
% 1st: Use for training
inputSeries = input(1:end-N);

targetSeries = output(1:end-N);
% 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 = input(end-N+1:end);
targetSeriesVal = output(end-N+1:end); % This is generally not available
%% 3. Network Architecture

delay = 10;

neuronsHiddenLayer = 7;

% Network Creation
net = narnet(1:delay,neuronsHiddenLayer);
net.divideFcn ='divideblock'
% view(net)
%% 4. Training the network

[Xs,Xi,Ai,Ts] = preparets(net,{},{},targetSeries);

net = train(net,Xs,Ts,Xi,Ai);

% view(net)

Y = net(Xs,Xi,Ai);

% Performance for the series-parallel implementation, only
% one-step-ahead prediction
perf = perform(net,Ts,Y);
hold all;
plot(delay+1:1:delay+length(Y),cell2mat(Y),'.');
%% 5. Multi-step ahead prediction

inputSeriesPred = [inputSeries(end-delay+1:end),inputSeriesVal];

% targetSeriesPred = [targetSeries(end-delay+1:end), con2seq(nan(1,N))];

netc = closeloop(net);

% view(netc)

[Xs,Xi,Ai,Ts] = preparets(netc,{},{},inputSeriesPred);

yPred = netc(Xs,Xi,Ai);

% plot(length(length(input)-N+1:1:length(input)),cell2mat(yPred));
figure();
plot(cell2mat(yPred),'r.');
hold all;
plot(cell2mat(targetSeriesVal),'b');
legend('predict','value');
perf = perform(net,yPred,targetSeriesVal);

Please help me.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.