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

训练报错 #42

Open
EddieEduardo opened this issue Jul 13, 2020 · 5 comments
Open

训练报错 #42

EddieEduardo opened this issue Jul 13, 2020 · 5 comments

Comments

@EddieEduardo
Copy link

你好博主,非常感谢分享。
我在按照提示的步骤进行训练时出现了如下的错误:
1 . Traceback (most recent call last):
File "yolov4-pytorch-master\nets\yolo4.py", line 129, in forward
P4 = torch.cat([P4,P5_upsample],axis=1)
TypeError: cat() got an unexpected keyword argument 'axis' (已将axis改成dim,请问这个是版本原因还是?)

2. Traceback (most recent call last):
File "yolov4-pytorch-master\nets\yolo_training.py", line 167, in forward
ciou = (1 - box_ciou( pred_boxes_for_ciou[mask.bool()], t_box[mask.bool()]))* box_loss_scale[mask.bool()]
AttributeError: 'Tensor' object has no attribute 'bool'(请问这个问题怎么进行修改呢?)

@ZZHHogan
Copy link

1.应该是版本问题,将P4 = torch.cat([P4,P5_upsample],axis=1) 改为 P4 = torch.cat([P4,P5_upsample],1 应该可以解决)
2. 首先定义一个equla_flag = torch.Tensor(0).cuda() ,然后再 ciou = (1 - box_ciou( pred_boxes_for_ciou[torch.equal(mask,equla_flag)],这个估计是版本问题,tensor中没有bool这个属性了。

不知道上述解决方法是否存在bug,如果有,请告知,谢谢!

@EddieEduardo
Copy link
Author

你好博主,非常感谢解答,问题已按照上述语句解决,即添加了:
equla_flag = torch.Tensor(0).cuda()
ciou = (1 - box_ciou( pred_boxes_for_ciou[torch.equal(mask,equla_flag)],
t_box[torch.equal(mask,equla_flag)]))*box_loss_scale[torch.equal(mask,equla_flag)]

同时还有2处:
1. ”nets\yolo_training.py", line 79, in box_ciou
center_distance = torch.sum(torch.pow((b1_xy - b2_xy), 2), axis=-1) #需要将axis去掉
2. “\nets\yolo_training.py", line 86, in box_ciou
enclose_diagonal = torch.sum(torch.pow(enclose_wh,2), axis=-1) #需要将axis去掉
请问博主,直接去掉会影响原代码意义吗?

@bubbliiiing
Copy link
Owner

这应该是版本问题吧,我忘了是高还是低的情况下是dim

@scau-gqw1993
Copy link

scau-gqw1993 commented Jun 11, 2021

1.应该是版本问题,将P4 = torch.cat([P4,P5_upsample],axis=1) 改为 P4 = torch.cat([P4,P5_upsample],1 应该可以解决)
2. 首先定义一个equla_flag = torch.Tensor(0).cuda() ,然后再 ciou = (1 - box_ciou( pred_boxes_for_ciou[torch.equal(mask,equla_flag)],这个估计是版本问题,tensor中没有bool这个属性了。

不知道上述解决方法是否存在bug,如果有,请告知,谢谢!

equal_flag = torch.Tensor(0).cuda()会不会写错了?我查了PyTorch文档,self.bool() is equivalent to self.to(torch.bool),改成mask.to(torch.bool)会不会更合适?链接:https://pytorch.org/docs/stable/tensors.html

@scau-gqw1993
Copy link

你好博主,非常感谢解答,问题已按照上述语句解决,即添加了:
equla_flag = torch.Tensor(0).cuda() ciou = (1 - box_ciou( pred_boxes_for_ciou[torch.equal(mask,equla_flag)], t_box[torch.equal(mask,equla_flag)]))*box_loss_scale[torch.equal(mask,equla_flag)]

同时还有2处:
1. ”nets\yolo_training.py", line 79, in box_ciou
center_distance = torch.sum(torch.pow((b1_xy - b2_xy), 2), axis=-1) #需要将axis去掉
2. “\nets\yolo_training.py", line 86, in box_ciou
enclose_diagonal = torch.sum(torch.pow(enclose_wh,2), axis=-1) #需要将axis去掉
请问博主,直接去掉会影响原代码意义吗?

equla_flag写错了吧,应该得是1,否则的话loss_loc不会被启用。

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

4 participants