torch.expand()
a=torch.rand(32,1)
a.expend(imgs.size())
>>>RuntimeError: The expanded size of the tensor (256) must match the existing size (32) at non-singleton dimension 2. Target sizes: [32, 1, 256, 170]. Tensor sizes: [32, 1]
a=torch.rand(32,1,1,1)
a.expend(imgs.size())
print(a.size())
>>>(32,1,256,170)