If I have a tensor like:
z = torch.FloatTensor([[1,2,3],[4,5,6]])
1 2 3
4 5 6
How might I turn it into a tensor like:
1 2 3
1 2 3
1 2 3
1 2 3
4 5 6
4 5 6
4 5 6
4 5 6
I imagine that torch.repeat() is somehow in play here.
The only solution I have come up with is to do:
z.repeat(1,4).view(-1, 3)
Is there one operation that collapses these two commands into one?
Moreover, if I have columnwise data I want to repeat, how can I do this without transposing the data back and forth? For example, going from
z = torch.FloatTensor([[1,2,3],[4,5,6],[7,8,9]])
1 2 3
4 5 6
7 8 9
to
1 1 1 2 2 2 3 3 3
4 4 4 5 5 5 6 6 6
7 7 7 8 8 8 9 9 9
without saying
z.transpose(0,1).repeat(1,3).view(-1, 3).transpose(0,1)