YOLOv3_PyTorch icon indicating copy to clipboard operation
YOLOv3_PyTorch copied to clipboard

A possible bug in training.py

Open lee2430 opened this issue 5 years ago • 2 comments

Dear @BobLiu20 , thanks for sharing your code. It's wonderful, however I think there might be a bug in the loss related block of training.py:

losses = [[]] * len(losses_name)
for i in range(3):
     _loss_item = yolo_losses[i](outputs[i], labels)
     for j, l in enumerate(_loss_item):
        losses[j].append(l)
losses = [sum(l) for l in losses]
loss = losses[0]

I suppose the losses should be a 7 * 3 list, but actually it appear to be of the size 7 * 21. Every time losses[j].append(l) is executed, l is appended to each sublist of losses. And after losses = [sum(l) for l in losses] is done, all the elements of 'losses' are identical. I doubt that this behavior is not like what the code is supposed to act. If I'm right, I think this issue can be addressed by changing losses = [[]] * len(losses_name) into:

losses = []
for i in range(len(losses_name)):
    losses.append([])

or something like that.

lee2430 avatar Jul 26 '18 06:07 lee2430

@lee2430 Hi, You are right! This is a bug.

BobLiu20 avatar Jul 27 '18 01:07 BobLiu20

Looks like the issue has been resolved. @BobLiu20 I leave you the honors to close this issue.

sordonia120446 avatar Aug 18 '18 14:08 sordonia120446