pytorch-YOLOv4 icon indicating copy to clipboard operation
pytorch-YOLOv4 copied to clipboard

Train problem

Open yunxiaozimeng opened this issue 5 years ago • 4 comments

when I train my own dataset ,I met a problem and the train process is ended,please help me

(base) E:\pytorch-YOLOv4-master>python train.py -l 0.001 -g 4 -pretrained ./yolov.pth -classes 2 -dir ./train/ log file path:log\log_2020-08-11_11-29-44.txt 2020-08-11 11:29:45,591 train.py[line:611] INFO: Using device cpu convalution havn't activate linear convalution havn't activate linear convalution havn't activate linear 2020-08-11 11:29:45,928 train.py[line:327] INFO: Starting training: Epochs: 10 Batch size: 4 Subdivisions: 4 Learning rate: 0.001 Training size: 12 Validation size: 12 Checkpoints: True Device: cpu Images size: 608 Optimizer: sgd Dataset classes: 2 Train label path:train.txt Pretrained:

Epoch 1/10: 33%|▎| 4/12 [00:39<01:19, 9.91s/img] Traceback (most recent call last): File "train.py", line 626, in device=device, ) File "train.py", line 380, in train loss, loss_xy, loss_wh, loss_obj, loss_cls, loss_l2 = criterion(bboxes_pred, bboxes) File "F:\anaconda3\lib\site-packages\torch\nn\modules\module.py", line 532, in call result = self.forward(*input, **kwargs) File "train.py", line 266, in forward weight=tgt_scale * tgt_scale, reduction='mean') File "F:\anaconda3\lib\site-packages\torch\nn\functional.py", line 2077, in binary_cross_entropy input, target, weight, reduction_enum) RuntimeError: Assertion `x >= 0. && x <= 1.' failed. input value should be between 0~1, but got -nan(ind) at C:\w\1\s\tmp_conda_3.7_10 0118\conda\conda-bld\pytorch_1579082551706\work\aten\src\THNN/generic/BCECriterion.c:53

yunxiaozimeng avatar Aug 11 '20 03:08 yunxiaozimeng

I met this problem, too. do u solve it?

in binary_cross_entropy input, target, weight, reduction_enum) RuntimeError: all elements of input should be between 0 and 1

arthur1060 avatar Aug 18 '20 04:08 arthur1060

Binary Crossentropy loss must have inputs between 0 and 1. Your labels are not between 0 and 1. I don't think you want to use binary crossentropy.

See this document for how to train yolov4 pytorch. Use Google Translate if you need: https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/master/Use_yolov4_to_train_your_own_data.md

Alternatively, you can train yolov4 natively with AlexeyAB's Darknet, then use pytorchyolov4 to convert the .weights file to pytorch weights. This option is more robust in my experience. https://github.com/AlexeyAB/darknet

stanleyjzheng avatar Aug 18 '20 17:08 stanleyjzheng

I met this problem, too. do u solve it?

in binary_cross_entropy input, target, weight, reduction_enum) RuntimeError: all elements of input should be between 0 and 1

Hello, i meet the same problem, did you solve it?

in binary_cross_entropy input, target, weight, reduction_enum) RuntimeError: all elements of input should be between 0 and 1

YeJunJie990 avatar Aug 16 '22 16:08 YeJunJie990

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

yunxiaozimeng avatar Aug 16 '22 16:08 yunxiaozimeng