How do you format data for a narxnet without preparets?

1 回表示 (過去 30 日間)
Natalie Cole
Natalie Cole 2016 年 3 月 14 日
回答済み: Greg Heath 2016 年 4 月 25 日
I have a series of scripts running on a computing cluster so the data is formatted without preparets to run in a feed-forward and time-delayed network. I would like to try the time-delay with feedback, but I'm having trouble setting up the inputs. I think the issue is with the feedback array.
  1 件のコメント
Dennis
Dennis 2016 年 4 月 24 日
編集済み: Dennis 2016 年 4 月 24 日
Asked myself the same question, because I created a C-Function representing my neural network with Matlab Coder. However, preparets cannot be coded into a C-Function, hence the question is appropriate.
I got around the issue by replacing preparets with self-written functions. I noticed that I just needed Xs, Xi and Ai from preparets and that Xs was just shifted by the exact number of zeros as my network contained delays. Then I made a scipt calculating thousands of Ai values for random input value combinations and trained a fitnet to calculate Ai from any input series. It worked well (since the fitnet can find the necessary equation for calculating Ai), but is no clean solution like finding out how those initial values have to be actually calculated.
I guess, what we both search for is another C-compatible function like "initialize()" or something.
However, if you can use Matlab to prepare your dataset, please use preparets to reshape the data and then directly use the network object to calculate the result:
[x,xi,ai,t] = preparets(net,X,{},T);
y = net(x,xi,ai);
Even if you want to calculate the resulting output y, you have to enter something for the target / output T in the correct length to make preparets work. I misunderstood that and entered nothing for T, which leads to preparets not working correctly.

サインインしてコメントする。

回答 (1 件)

Greg Heath
Greg Heath 2016 年 4 月 25 日
Using preparets on the narxnet documentation example to deduce the answer:
Although I used the default input delay ID = 1:2, I used the nondefault value FD = 1:3 for the output feedback delay.
% NOTATION: Upper case for cells, 'o' and OL for openloop
close all, clear all, clc
[ X, T ] = simplenarx_dataset;
ID = 1:2, FD = 1:3, H = 10
neto = narxnet( ID, FD, H );
X14 = X(1:4)%[0.31122] [0.52853] [0.16565] [0.60198]
T14 = T(1:4)%[0.81158] [0.53283] [0.95973] [0.57073]
[ Xo, Xoi, Aoi, To ] = preparets(neto, X, {} ,T );
xo = cell2mat(Xo); to = cell2mat(To);
whos X T Xo Xoi Aoi To xo to
% Name Size Bytes Class
% Aoi 2x0 0 cell
% T 1x100 12000 cell
% To 1x97 11760 cell
% X 1x100 12000 cell
% Xo 2x97 23520 cell
% Xoi 2x3 480 cell
% to 1x97 784 double
% xo 2x97 1568 double
isequal( Aoi, cell(2,0) ) % 1
isequal( To, T( 4:end) ) % 1
isequal( Xo, [ X(4:end); T(4:end)] )% 1
isequal( Xoi, [ X(1:3) ; T(1:3) ] )% 1
NOTICE: SINCE length(FD) > length(ID) Xoi has to include X(3).
It is not clear that this is a BUG. However other cases of FD ~= ID need to be investigated further.
Hope this helps.
Thank you for formally acceptingmy answer
Greg

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by