Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
caesar-yabo opened this issue Jul 26, 2019 · 10 comments

Comments

@caesar-yabo
Copy link

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

@caesar-yabo caesar-yabo changed the title 稀疏化训练时出现这个错,没明白原因。希望打捞给点建议RuntimeError: cannot perform reduction function max 稀疏化训练时出现这个错,没明白原因。希望大佬给点建议RuntimeError: cannot perform reduction function max Jul 26, 2019
@leJson
Copy link

leJson commented Jul 27, 2019

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

@liaoyunkun
Copy link

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

@leJson
Copy link

leJson commented Jul 29, 2019

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

我跑的自己的数据,

@PiseyYou
Copy link

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
Copy link

leJson commented Jul 30, 2019

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
Copy link

@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
Copy link

Yapths commented Jul 30, 2019

@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
Copy link

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
Copy link

Yapths commented Jul 30, 2019

I have ignored parse_config.py ,thanks for your information

@Yapths
Copy link

Yapths commented Jul 30, 2019

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。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants