필터 지우기
필터 지우기

Deep Learning Error - how to fix code?

조회 수: 3 (최근 30일)
Manny
Manny 2024년 2월 27일
답변: Venu 2024년 3월 7일
I am using this link to implement a deep learning algorithim:
I followed most of the steps but modified slightly to fit my data. I am getting an error. How do I fix it?
Here is my code:
FilteredCIV = CIV(strcmp(CIV.SYMBOL,UnderlyingSymbols.SYMBOL(i)),:);
FilteredCIV = FilteredCIV(FilteredCIV{:,2} <= datenum(2024,2,5),:);
FilteredCIVOnly = table2array(FilteredCIV(:,"COMPOSITE_IMPLIED_VOLATILITY"));
net = narnet(1:2,10,'none','trainbr');
[Xs,Xi,Ai,Ts] = preparets(net,{},{},FilteredCIVOnly);
net = train(net,Xs,Ts,Xi,Ai);
[Y,Xf,Af] = net(Xs,Xi,Ai);
[netc,Xic,Aic] = closeloop(net,Xf,Af);
Yc = netc(cell(0,20),Xic,Aic);
Here is CIV table:
>> CIV
CIV =
2452×3 table
SYMBOL TRADE_DATE COMPOSITE_IMPLIED_VOLATILITY
_______ __________ ____________________________
{'SPX'} 7.3585e+05 12.596
{'SPX'} 7.3585e+05 13.243
{'SPX'} 7.3585e+05 13.868
{'SPX'} 7.3585e+05 13.621
{'SPX'} 7.3585e+05 14.706
Here is error:
Index in position 2 exceeds array bounds. Index must not exceed 1.
Error in preparets (line 317)
xi = xx(:,FBS+((1-net.numInputDelays):0));
Error in ForecastModel (line 58)
[Xs,Xi,Ai,Ts] = preparets(net,{},{},FilteredCIVOnly);
Thank you

답변 (1개)

Venu
Venu 2024년 3월 7일
Hi @Manny,
To pass the data properly to preparets, make these two adjustments in your code.
  • Pass FilteredCIVOnly as a cell array; FilteredCIVOnlyCell = num2cell(FilteredCIVOnly);
  • Transpose FilteredCIVOnlyCell to ensure that the data is correctly interpreted as a sequence of timesteps by the function; [Xs,Xi,Ai,Ts] = preparets(net, {}, {}, FilteredCIVOnlyCell');
Hope this helps!

카테고리

Help CenterFile Exchange에서 Pattern Recognition and Classification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by