MATLAB Answers

What is the mean of "Error using builtin" when using trainNetwork?

9 views (last 30 days)
jhe en lin
jhe en lin on 17 Dec 2019
Answered: Sourav Bairagya on 20 Dec 2019
I use the way introduced in this link to train my network, but when I finish creating training data and validation data, it shows a error message below.
Error using trainNetwork (line 170)
Invalid input array.
Error in NetworkTest (line 53)
net = trainNetwork(dsTrain,lgraph,options);
Caused by:
Error using builtin
Invalid input array.
I have no idea how to fix this problem. Is it mean that I create the wrong training data and vadiation data?
Here is my code about training. (I set training data and validation data the same because I only want to test whether the program works or not first)
%read input imag, each mat file is 32*32*20
imdsTrain = imageDatastore('TrainData/*', ...
'FileExtensions','.mat','ReadFcn',@(x) matRead(x));
%read target imag, each mat file is 32*64*20
imdsTarget = imageDatastore('GroundTruth/*', ...
'FileExtensions','.mat','ReadFcn',@(x) matRead(x));
dsTrain = combine(imdsTrain,imdsTarget);
dsVal = combine(imdsTrain,imdsTarget);
imdsTrain.ReadSize = 10;
imdsTarget.ReadSize = 10;
options = trainingOptions('adam', ...
'MaxEpochs',100, ...
'MiniBatchSize',imdsTrain.ReadSize, ...
'ValidationData',dsVal, ...
'Shuffle','never', ...
'Plots','training-progress', ...
'Verbose',false);
net = trainNetwork(dsTrain,lgraph,options); %line 53

Answers (1)

Sourav Bairagya
Sourav Bairagya on 20 Dec 2019
It seems that data stored in the '.mat' file may have some error. Hence, it would be better to check the dimesnions of those data and match those with the input and output size of the network.

  0 Comments

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!