RuntimeError: stack expects each tensor to be equal size, but got [1, 5] at entry 0 and [3, 5] at en

相关参考 :https://blog.csdn.net/yuxiang8546/article/details/118761999

原因是batch_size 里的图像大小不一样,解决方法如下:

在 dataset 类里 添加

def yolo_dataset_collate(batch):
    images = []
    bboxes = []
    for img, box in batch:
        images.append(img)
        bboxes.append(box)
    images = np.array(images)
    return images, bboxes

和做 如下修改

RuntimeError: stack expects each tensor to be equal size, but got [1, 5] at entry 0 and [3, 5] at en_第1张图片

你可能感兴趣的:(python,与,pytorch,pytorch)