observationDim should be either 2, 3, 4 or 5

1 visualización (últimos 30 días)
Marc Dirix
Marc Dirix el 2 de Mzo. de 2023
Respondida: Sai Kiran el 6 de Mzo. de 2023
Hi, sorry about noob question.
I am trying to adapt the TrainNetworkOnImageAndFeatureDataExample.mlx to my use case. I my use case I only have the training image data and the categories, the "X2Train" feature input is absent. Thus my layers now look as follows:
[h,w,numChannels,numObservations] = size(trainData);
numFeatures = 1;
numClasses = numel(categories(trainLabels));
imageInputSize = [h w numChannels];
filterSize = 5;
numFilters = 16;
layers = [
imageInputLayer(imageInputSize,Normalization="none")
convolution2dLayer(filterSize,numFilters)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(50)
flattenLayer
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer
];
%concatenationLayer(1,2,Name="cat")
lgraph = layerGraph(layers);
When running the trainNetwork I get an error:
observationDim should be either 2, 3, 4 or 5
But I have no clue whatsoever what I need to change here.

Respuestas (1)

Sai Kiran
Sai Kiran el 6 de Mzo. de 2023
Hi,
The error is due to mismatch in the dimensions of two matrices while multiplying them.
The layers doesn't have any errors when we pass another dataset.
Please check the dimensions of 'trainData' and 'trainLabels' and the command window , it shows where the error has occured at a specific line in the code.
I hope it helps!

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by