Solved by albanD in post #2 
              
              
                Hi, 
If you are sure they contain the same number of non zero elements D, you can do x[b].view(D, N). If you want an [N, D] result, you can transpose that with .t().