pytorch-YOLOv4 icon indicating copy to clipboard operation
pytorch-YOLOv4 copied to clipboard

RuntimeError: view size is not compatible with input tensor's size and stride

Open mikel-brostrom opened this issue 2 years ago • 1 comments

Got this error:

File "train.py", line 211, in build_target
    pred_ious = bboxes_iou(pred[b].view(-1, 4), truth_box, xyxy=False)
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

Solved it by changing view:

https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/a65d219f9066bae4e12003bd7cdc04531860c672/train.py#L211

to reshape

mikel-brostrom avatar Jan 31 '23 09:01 mikel-brostrom

在view前面加.contiguous()

J1ia avatar Feb 25 '23 08:02 J1ia