Thanks for the correction regarding the last state / output, as I’ve clearly mixed up the return values. 



 shivin7:

But I can’t understand why view doesn’t work here. What do you mean by interleaving the signal?


Have a look at this example:
 x = torch.arange(2*4*5).view(2, 4, 5)
print(x)

# Now permute the dimensions
print(x.permute(0, 2, 1)) # rows and columns for each sample in dim0 are swapped

# Wrong permutation!
print(x.view(2, 5, 4)) # result is interleaved

Here you can see, that I would like to swap the last two dimensions (basically transpose dim1 and dim2 for each sample in the batch dimension).
.permute does the job right, while view just changes the stride and shape and thus will create a wrong and interleaved result.
By “interleaved” I mean that the original row tensors are cut and the remaining elements are added to the next row.