Expand a tendor


(linyu) #1

I have an origin tensor [0,1;2,3], how can I efficiently get [0,0,1,1;0,0,1,1;2,2,3,3;2,2,3,3]?


(Yunusemre) #2

I think this post should help you:

As mentioned here How to tile a tensor?, we can build wit .repeat() and .view(). For your solution: a.view(-1, 1).repeat(1,2).view(2,4).repeat(1,2).view(4,4)