Hello, I am trying to use MATLABS RNN function layrecnet to do one step ahead prediction. But it does not let me use "removedelay" as in other examples, resulting in an error.
There must be another way to do it, I am wondering how to get one-step ahead prediction working with the RNN?
neto = layrecnet(inputDelays,hiddenLayerSize); [Xo,Xoi,Aoi,To] = preparets(neto,Xorig,Torig); [ neto, tro, Yo, Eo, Xof, Aof ] = train(neto,Xo,To,Xoi,Aoi); view(neto) Yo = neto(Xo,Xoi,Aoi); to = cell2mat(To); MSE00o = mean(var(to',1)) % Normalization Referenc
NMSEo = mse(Eo)/MSE00o R2o = 1 - NMSEo yo = cell2mat(Yo); nets = removedelay(neto);
>> nets = removedelay(neto); Error using removedelay (line 57) Removing 1 to input delays would result in a negative input weight delay.
The layrecnet help mentioned using removedelay to do prediction, but I think the help is wrong.
>> help layrecnet layrecnet Layered recurrent neural network.
Layer recurrent networks with two (or more) layers can learn to predict any dynamic output from past inputs given enough hidden neurons and enough recurrent layer delays. layrecnet(layerDelays,hiddenSizes,trainFcn) takes a row vectors of layers delays, a row vector of hidden layer sizes, and a backpropagation training function, and returns a layer recurrent neural network with N+1 layers. Input, output and output layers sizes are set to 0. These sizes will automatically be configured to match particular data by train. Or the user can manually configure inputs and outputs with configure. Defaults are used if layrecnet is called with fewer arguments. The default arguments are (1:2,10,'trainlm'). Here a layer recurrent network is used to solve a time series problem. [X,T] = simpleseries_dataset; net = layrecnet(1:2,10); [Xs,Xi,Ai,Ts] = preparets(net,X,T); net = train(net,Xs,Ts,Xi,Ai); view(net); Y = net(Xs,Xi,Ai); perf = perform(net,Y,Ts) To predict the next output a step ahead of when it will occur: net = removedelay(net); [Xs,Xi,Ai,Ts] = preparets(net,X,T); Y = net(Xs,Xi,Ai); See also narxnet, timedelaynet, distdelaynet. Reference page in Help browser doc layrecnet
Best Answer