Yolov4 code problem
이전 댓글 표시
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
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
2024년 8월 31일
Gojo
2024년 9월 3일
Could you share the relevant code files and reproduction steps so that I could try at my end.
sungho
2024년 9월 3일
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
2024년 9월 4일
카테고리
도움말 센터 및 File Exchange에서 Parallel and Cloud에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!