trainNetwork in MATLAB after several iterations gives error: Array dimensions being concatenated are inconsistent?

5 views (last 30 days)
I am currently working on several CNNs for regression. After several iterations (btw 1500-3000 something) of training a similar architecture as V-net by Miletari and a less deep multi-input CNN architecture the training stops due to the error below.
Error using trainNetwork
Dimensions of arrays being concatenated are not consistent.
Error in net
[net,info] = trainNetwork(ds,lgraph,options);
Caused by:
Error using cat
Dimensions of arrays being concatenated are not consistent
The function
shows no warnings or errors.
Did anyone experience the same issue and could tackle the reason for the issue?

Accepted Answer

Srivardhan Gadila
Srivardhan Gadila on 14 Apr 2021
As per my knowledge, when using datastores and batchSize greater than 1 all the training samples should be of same size. The trainNetwork function combines multiple training samples of batchSize together and gives it to the network. If the those samples are not having the same size then you will be getting the above mentioned error.
Try checking if all the trianing samples are of the same size by using read on the datastore.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by