Yolov4 code problem
8 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
Shubham
2024-8-31
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 个评论
Shubham
2024-9-4
编辑:Shubham
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?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Trees 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!