필터 지우기
필터 지우기

observationDim should be either 2, 3, 4 or 5

조회 수: 7 (최근 30일)
Marc Dirix
Marc Dirix 2023년 3월 2일
답변: Sai Kiran 2023년 3월 6일
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.

답변 (1개)

Sai Kiran
Sai Kiran 2023년 3월 6일
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!

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by