talebolano / yolov3-network-slimming

yolov3 network slimming剪枝的一种实现
345 stars 93 forks source link

稀疏化训练时出现这个错,没明白原因。希望大佬给点建议RuntimeError: cannot perform reduction function max #29

Open caesar-yabo opened 5 years ago

caesar-yabo commented 5 years ago

load network done! load weightsfile done! Traceback (most recent call last): File "sparsity_train.py", line 154, in train() File "sparsity_train.py", line 100, in train loss = model(imgs, targets) File "/home/caesar/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call result = self.forward(*input, kwargs) File "/home/caesar/deep/yolov3_limming/yolomodel.py", line 353, in forward x, losses = self.module_list[i][0](x, targets) File "/home/caesar/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call result = self.forward(input, kwargs) File "/home/caesar/deep/yolov3_limming/yolomodel.py", line 136, in forward loss_cls = (1 / nB) * self.ce_loss(pred_cls[mask], torch.argmax(tcls[mask], 1)) RuntimeError: cannot perform reduction function max on tensor with no elements because the operation does not have an identity

leJson commented 5 years ago

感觉有点像没有加载对labels文件,所以没法去计算loss,你可以看看有没有加载到对应图片的labels文件

liaoyunkun commented 5 years ago

@leJson 你是在Pascal Voc上跑这个吗?

leJson commented 5 years ago

@leJson 你是在Pascal Voc上跑这个吗?

我跑的自己的数据,

PiseyYou commented 5 years ago

result = self.forward(*input, *kwargs) File "/ext_data/anaconda3_before/envs/yolo/yolov3-network-slimming/yolomodel.py", line 130, in forward loss_cls = (1 / nB) self.ce_loss(pred_cls[mask], torch.argmax(tcls[mask], 1)) RuntimeError: cannot perform reduction function max on tensor with no elements because the operation does not have an identity

The same error happen, the original use coco dataset, run in ubuntu 16.04

have you already solve the issue?@caesar-yabo

leJson commented 5 years ago

result = self.forward(*input, *kwargs) File "/ext_data/anaconda3_before/envs/yolo/yolov3-network-slimming/yolomodel.py", line 130, in forward loss_cls = (1 / nB) self.ce_loss(pred_cls[mask], torch.argmax(tcls[mask], 1)) RuntimeError: cannot perform reduction function max on tensor with no elements because the operation does not have an identity

The same error happen, the original use coco dataset, run in ubuntu 16.04

have you already solve the issue?@caesar-yabo

楼上有答案的,你仔细看看,是不是加载图像的时候路径错了.这个报错一般是没加载到数据

PiseyYou commented 5 years ago

@leJson Thanks a lot, I solve the issue, the key point is put folder "images" and "label" at the same folder. The folder path as below: This make clear how to solver the label issue.

. ├── 5k.part ├── 5k.txt ├── images │   ├── train2014 │   ├── val2014 ├── labels │   ├── train2014 │   └── val2014

Yapths commented 5 years ago

@leJson Thanks a lot, I solve the issue, the key point is put folder "images" and "label" at the same folder. The folder path as below: This make clear how to solver the label issue.

. ├── 5k.part ├── 5k.txt ├── images │   ├── train2014 │   ├── val2014 ├── labels │   ├── train2014 │   └── val2014

Can you show us the VOC data? thanks

PiseyYou commented 5 years ago

I was doing the task for test coco, not VOC right now, after check this, I will these test later. As I get the information, the key point to deal with VOC data is you need to change the parse_config.py. In the code, you need to change "images" to "JPEGImages"

line 41 : (self.label_files = [path.replace('JPEGImages', 'labels').replace('.png', ........)

if this is not working, modify utils/datasets.py,‘images’ to ‘’JPEGImages is suggetion. I don't test yet, but the information you can have a try.

Yapths commented 5 years ago

I have ignored parse_config.py ,thanks for your information

Yapths commented 5 years ago

I was doing the task for test coco, not VOC right now, after check this, I will these test later. As I get the information, the key point to deal with VOC data is you need to change the parse_config.py. In the code, you need to change "images" to "JPEGImages"

line 41 : (self.label_files = [path.replace('JPEGImages', 'labels').replace('.png', ........)

if this is not working, modify utils/datasets.py,‘images’ to ‘’JPEGImages is suggetion. I don't test yet, but the information you can have a try.

Thanks for your information!I have solved the problem!The labels data is not loaded in!you should check your parse_config.py to see if it has loaded your labels。