ptrblck:

torch.stack((a, b), dim=0).view(2, 4).t().contiguous().view(2, 4)


How come you don’t do
torch.stack((a,b), dim=2).view(2,4)
>> tensor([[ 1.,  2.,  1.,  2.],
           [ 1.,  2.,  1.,  2.]])

Similarly, the vertical interleave can be:
torch.stack((a,b), dim=1).view(4,2)
>> tensor([[ 1.,  1.],
           [ 2.,  2.],
           [ 1.,  1.],
           [ 2.,  2.]])

I just started using pytorch on version 0.4 so maybe it’s something they added recently. Also, I’m sure there’s a good reason you’ve made calls to contiguous(), is there something I should know about the view?