How to get metrics during yolov4 detector training process and how to solve data overfitting?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
xinru
el 12 de Ag. de 2024
When i use yolov4 detector to achieve a single-class target detection tasks, i can only get training-loss and validation-loss after training process.I have tried to use "options" to get metrics ,but it made Errow, wrong use " nnet.cnn.TrainingOptions/validateDataFormatsAndMetricsAreEmpty ,trainYOLOv4ObjectDetector can't support 'Metrics' training options",my code and errow are below:
Then how to get metrics during yolov4 detector training process?
----------------------------------------------------------------------------------------------
Meanwhile, after fine-tuning options parameters,I have trained the detector many times, the final training loss maintains 0.1 while validation loss can only get 2.0, how can I avoid this data overfitting?I've tried many methods , if you can give me some suggestions , it will be very helpful .
0 comentarios
Respuesta aceptada
Gayathri
el 13 de Ag. de 2024
As the error suggests, its not possible to pass “metrics” option in “trainingOptions” for “YOLOv4ObjectDetector”. Instead I can suggest you to use “evaluateObjectDetection” function to obtain the metrics Precision, Recall and Accuracy. This function also provides the confusion matrix through which all metrics could be calculated.
detectionresults=detect(trainedDetector,imds)
%%%%%%%%%%%%%Calculate metrics
metrics = evaluateObjectDetection(detectionresults, blds)
%%To obtain confusion matrix
cm=metrics.ConfusionMatrix
%%To obtain Precision,recall and AP
recall = metrics.ClassMetrics{"vehicle","Recall"}
precision = metrics.ClassMetrics{"vehicle","Precision"}
ap = metrics.ClassMetrics{"vehicle","AP"}
For additional information and example about “evaluateObjectDetection” please refer to https://www.mathworks.com/help/vision/ref/evaluateobjectdetection.html
To avoid overfitting, you can try training with more data. That would help mitigate overfitting.
Hope you find this information helpful.
2 comentarios
Gayathri
el 16 de Ag. de 2024
Editada: Gayathri
el 16 de Ag. de 2024
Hi, yes we should be using test data. The code provided was just for illustrating the function usage. For overfitting, you can also try reducing the learning rate from 0.01 to 0.001 or lesser, if you have not tried this earlier. A learning rate that is high might cause the model to converge too quickly on the training data, leading to overfitting.
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!