- 问题 1
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 339 and 372 in dimension 2 at /pytorch/aten/src/TH/generic/THTensor.cpp:612
网上查找之后,应该是因为不同图片的size 维度不对造成的;于是我在dataset.py
生成data那里,每一张图都进行了crop 于是这个问题解决了。
- 问题2
input_img = input_img.crop(0, 0, 125, 125)
TypeError: crop() takes from 1 to 2 positional arguments but 5 were given
我在这里犯的低级错误
记得crop的时候里面那个box 加[0,0,125,125]
记得自己最终训练的时候,要使用中心裁剪或者随机裁剪,选出一个500 500大小的范围
总之要保证每一个batch里面的图片大小是一样的
- loss.backward()