Fix the device inconsistency error in yolov7 training (#397)

* [FIX] Indices should be either on cpu or on the same device as the indexed tensor

* fix lint error

* use new_full instead of simple torch.ones

* fix lint error

* fix type error

* use existed tensor to create new_full tensor

Co-authored-by: zhubochao <zhubochao@zhubochaodeMacBook-Pro.local>
pull/362/head
zhubochao 2022-12-27 11:54:28 +08:00 committed by GitHub
parent 46e7f6a477
commit 6c5acd238c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -227,7 +227,8 @@ class BatchYOLOv7Assigner(nn.Module):
_mlvl_priors.append(priors)
_from_which_layer.append(
torch.ones(size=(_mlvl_positive_info.shape[0], )) * i)
_mlvl_positive_info.new_full(
size=(_mlvl_positive_info.shape[0], ), fill_value=i))
# (n,85)
level_batch_idx, prior_ind, \