Closed alwc closed 4 years ago
y should be divided by width while x should be modded by width. For examples
y
width
x
>>> mat = torch.arange(0, 12) tensor([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) >>> mat.reshape(4, -1) tensor([[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8], [ 9, 10, 11]]) >>> height, width = mat.shape >>> torch.arange(0, 12) / width # for y-coordinate tensor([0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) >>> torch.arange(0, 12) % width # for x-coordinate tensor([0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2])
y
should be divided bywidth
whilex
should be modded bywidth
. For examples