torch
torch copied to clipboard
torch_tile not working as expected
torch_tile() seems to be expecting its dim argument to follow R dimension numbering convention (1, 2, ...) and subtracts 1 before passing on the call - but dim here really stands for number of repetitions per dimension:
> t <- torch_tensor(rbind(c(1, 2), c(3,4)))
> t$tile(c(2, 2))
torch_tensor
1 2
3 4
[ CPUFloatType{2,2} ]
> t$tile(c(3, 3))
torch_tensor
1 2 1 2
3 4 3 4
1 2 1 2
3 4 3 4
[ CPUFloatType{4,4} ]
compare https://pytorch.org/docs/stable/generated/torch.tile.html#torch.tile:
>>> y = torch.tensor([[1, 2], [3, 4]])
>>> torch.tile(y, (2, 2))
tensor([[1, 2, 1, 2],
[3, 4, 3, 4],
[1, 2, 1, 2],
[3, 4, 3, 4]])