trainNetwork error RESHAPE line 260

조회 수: 2 (최근 30일)
Elaine Todd
Elaine Todd 2020년 2월 7일
답변: Sourav Bairagya 2020년 2월 12일
Hi! I'm trying to make a classification network, but I keep running into an error in trainNetwork and I'm having a hard time figuring it out. This is the error I'm getting
Error using trainNetwork (line 170)
To RESHAPE the number of elements must not change.
Error in train2 (line 7)
trained_net = trainNetwork(X,Y,layers,options);
Error in Crashworthiness_NN (line 24)
trained_net = train2(X,Y, layers);
Caused by:
Error using reshape
To RESHAPE the number of elements must not change.
Using the debugging tool I've realized that the code runs until line 260 trainedNet = trainer.train(trainedNet, trainingDispatcher); during the call from line 170. I'm not sure what I'm doing wrong. Here is the code I have
layers = [sequenceInputLayer([100,5,1])
flattenLayer
bilstmLayer(100)
fullyConnectedLayer(10)
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
trained_net = train2(X,Y, layers);
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);
where X is a 100x5 double and Y is a 100x1 categorical. I'm new to the deeplearning toolbox so I'm not 100% how everything works so this may be a simple mistake but I can't figure it out.
Thanks!

답변 (1개)

Sourav Bairagya
Sourav Bairagya 2020년 2월 12일
It seems that the error lies in using 'reshape' function in 'Crashworthiness_NN'. It may be possible that the number of elements in the input of the 'reshape' is not equal to the number of elements in output. It will be good to check the dimensions of input and output once.

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by