```
import torch
import numpy as np
a = torch.tensor([[1, 4], [2, 5],[3, 6]])
b = a.view(6).detach().numpy()
```

The b is[ 1 4 2 5 3 6]

how to use reshape or other function, without for loop, so that b is [1 2 3 4 5 6]

This is just an example, want some generic answers, even 3D

Here is the solution but only for Numpy (from other forum), can anyone helps with Torch

```
In [73]: a.ravel(order='F')
Out[73]: array([1, 2, 3, 4, 5, 6])
```

You could transpose the tensor and flatten it afterwards:

```
a = torch.tensor([[1, 4], [2, 5],[3, 6]])
b = a.t().contiguous().view(-1)
print(b)
# tensor([1, 2, 3, 4, 5, 6])
```

I canâ€™t give a generic answer as the reshape operations would depend on the actual data and what your expectation would be. Transposing could certainly work, but you would have to provide examples.