这里为什么要多一个1呢?
wu462 opened this issue · comments
wingpeaks commented
def get_output_and_grid(self, output, k, stride, dtype):
grid = self.grids[k]
batch_size = output.shape[0]
n_ch = 5 + self.num_classes
hsize, wsize = output.shape[-2:]
if grid.shape[2:4] != output.shape[2:4]:
yv, xv = meshgrid([torch.arange(hsize), torch.arange(wsize)])
grid = torch.stack((xv, yv), 2).view(1, 1, hsize, wsize, 2).type(dtype) # 这里为什么要多一个1呢?
self.grids[k] = grid
output = output.view(batch_size, 1, n_ch, hsize, wsize) # 这里为什么要多一个1呢?
output = output.permute(0, 1, 3, 4, 2).reshape(
batch_size, hsize * wsize, -1
)
grid = grid.view(1, -1, 2)
output[..., :2] = (output[..., :2] + grid) * stride
output[..., 2:4] = torch.exp(output[..., 2:4]) * stride
return output, grid
wingpeaks commented
为了说明1个anchor?
kv1830 commented
我觉得你说的对~~,就是为了说明一个anchor