trainNetwork RESHAPE error line 170

12 ビュー (過去 30 日間)
Elaine Todd
Elaine Todd 2020 年 2 月 3 日
コメント済み: Namasi Gomathi 2020 年 5 月 10 日
Hi. I keep getting this error
Error using trainNetwork (line 170)
To RESHAPE the number of elements must not change.
I'm not quite sure what I am doing wrong since the trainNetwork function is kinda hard to understand without spending hours on going through it.
This is my code. My X is a 100x5 double and my Y is a 100x1 categorical.
layers = [sequenceInputLayer([100,5,1])
flattenLayer
bilstmLayer(100)
fullyConnectedLayer(10)
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
trained_net = train2(X,Y, layers);
Train2 function
function trained_net = train2(X,Y, layers)
% creates adam optimizer
options = trainingOptions('adam', 'InitialLearnRate',3e-4, ...
'SquaredGradientDecayFactor',0.99, 'MaxEpochs',20, ...
'MiniBatchSize',10, 'Plots','training-progress');
% trains network
trained_net = trainNetwork(X,Y,layers,options);

回答 (1 件)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020 年 2 月 6 日
Hello Elaine,
The code that you have written fails in the input validation phase of trainNetwork. The output size of the network does not match the size of the response data. Since you are defining a classification network, the output is a “classes mismatch” error. You may have to revisit the definition of layers to solve the problem.
Consider using the MATLAB debugging tools to pinpoint areas of code which is creating the error.
Hope this helps!
  3 件のコメント
Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020 年 2 月 10 日
Hey Elaine,
Which version of MATLAB are you using?
Namasi Gomathi
Namasi Gomathi 2020 年 5 月 10 日
Im facing the same problem on R2020a

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

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by