hi guys, i need to help to fix my code error.
to train yolov4 model for my dataset. i put right input size and everything. but happend error again and again.
error code is like this
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
Error in trainYOLOv4ObjectDetector>iGetMaxIOUPredictedWithGroundTruth (line 425)
iou(:,:,:,batchSize) = reshape(maxOverlap,h,w,c);
Error in trainYOLOv4ObjectDetector>iGenerateTargets (line 319)
iou = iGetMaxIOUPredictedWithGroundTruth(bx,by,bw,bh,groundTruth);
Error in trainYOLOv4ObjectDetector>calculateLoss (line 234)
[boxTarget, objectnessTarget, classTarget, objectMaskTarget, boxErrorScale] = iGenerateTargets(gatheredPredictions, YTrain, params.InputSize, params.AnchorBoxes, penaltyThreshold);
Error in trainYOLOv4ObjectDetector>@(varargin)calculateLoss(lossParams,varargin) (line 167)
lossFcn = @(varargin) calculateLoss(lossParams,varargin);
Error in images.dltrain.internal.SerialTrainer>modelGradients (line 139)
loss = lossFcn(networkOutputs{:},targets{:});
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in deep.internal.dlfevalWithNestingCheck (line 15)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:});
Error in images.dltrain.internal.SerialTrainer/fit (line 76)
[loss,grad,state,networkOutputs,lossData] = dlfeval(@modelGradients,self.Network,self.LossFcn,...
Error in images.dltrain.internal.dltrain (line 102)
net = fit(networkTrainer);
Error in trainYOLOv4ObjectDetector (line 183)
[trainedDetector,infoTrain] = images.dltrain.internal.dltrain(mbq,detector,options,lossFcn,metrics,validationPatienceMetric,'ExperimentMonitor',params.ExperimentMonitor);

답변 (1개)

Gojo
Gojo 2024년 8월 31일

0 개 추천

Hey Sungho,
It appears that you’re encountering an issue with the ’reshape’ function in your YOLOv4 model. The error message being encountered during the training of a YOLOv4 object detector in MATLAB suggests an issue with the reshaping of arrays within the function ‘iGetMaxIOUPredictedWithGroundTruth’. This error often arises due to a mismatch in expected dimensions during operations like reshaping or concatenation.
I believe you can refer to the following MATLAB Answer which discusses the similar issue with the same stack trace here: https://www.mathworks.com/matlabcentral/answers/2146179-how-i-can-fix-internal-change-in-number-of-elements-in-yolo-v4-network-while-training
I hope this would resolve the issue!

댓글 수: 5

sungho
sungho 2024년 8월 31일
i read that one.. but i couldn't fix my problem...
Gojo
Gojo 2024년 9월 3일
Could you share the relevant code files and reproduction steps so that I could try at my end.
sungho
sungho 2024년 9월 3일
how can i share it?? if you tell me then i will try to share it.
and i try training separately to find problem. and i think training file has some problem.
i have 3 training folder. 2 folder has problem and 1 folder was success.
Gojo
Gojo 2024년 9월 4일
편집: Gojo 2024년 9월 4일
Use the paperclip icon in the 'INSERT' section to attach any relevant files.
Also what are you doing different for the three training folders? I don't think this would be a sporadic error. Also if you are able to run it over one of the folder, then has it resolved the issue you are facing?
sungho
sungho 2024년 9월 4일
i found problem. if i train bbox = xmin, ymin, bboxWidth, bboxHeight then, reshape error code happend. and i try with bbox = centerX, centerY, bboxWidth, bboxHeight then training was successful without error. can you advise about it?

댓글을 달려면 로그인하십시오.

카테고리

질문:

2024년 8월 31일

댓글:

2024년 9월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by