Layers argument must be an array of layers or a layer graph.

조회 수: 3 (최근 30일)
PRAMOD A
PRAMOD A 2024년 2월 7일
답변: Krishna 2024년 2월 10일
XTrain = xlsread('R1_all_data.xlsx',1,'A1:G3788')';
YTrain = xlsread('R1_all_data.xlsx',1, 'H1:H3788')';
XTest = xlsread('R2_all_data.xlsx',1, 'A1:G3788')';
YTest = xlsread('R2_all_data.xlsx',1, 'H1:H3788')';
inputSize = 3788;
numResponses = 1;
numHiddenUnits = 5000;
layers = { sequenceInputLayer(inputSize)
lstmLayer(numHiddenUnits)
fullyConnectedLayer(numResponses)
regressionLayer };
opts = trainingOptions('adam', 'MaxEpochs', 1000, 'GradientThreshold', 0.01, 'InitialLearnRate',0.0001);
net = trainNetwork(XTrain,YTrain,layers,opts);
YPred1=predict(net,XTest)
  댓글 수: 1
Matt J
Matt J 2024년 2월 7일
편집: Matt J 2024년 2월 7일
You have posted only code. Do you have a question about it? If you are getting error messages please copy/paste them.

댓글을 달려면 로그인하십시오.

답변 (1개)

Krishna
Krishna 2024년 2월 10일
Hello PRAMOD,
It appears that the issue you're encountering stems from an improper initialization of the layers object. The mistake was made by using curly braces {} to initialize:
layers = { sequenceInputLayer(inputSize)
lstmLayer(numHiddenUnits)
fullyConnectedLayer(numResponses)
regressionLayer }
Instead, you should initialize using square brackets [] like this:
layers = [ sequenceInputLayer(inputSize)
lstmLayer(numHiddenUnits)
fullyConnectedLayer(numResponses)
regressionLayer ]
I hope this correction resolves your problem.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by