Example 1: pytorch squeeze
x = torch.zeros(2, 1, 2, 1, 2)
x.size()
>>> torch.Size([2, 1, 2, 1, 2])
y = torch.squeeze(x)
y.size()
>>> torch.Size([2, 2, 2])
y = torch.squeeze(x, 0)
y.size()
>>> torch.Size([2, 1, 2, 1, 2])
y = torch.squeeze(x, 1)
y.size()
>>> torch.Size([2, 2, 1, 2])
Example 2: reshape python
>>> np.reshape(a, (2, 3))
array([[0, 1, 2],
[3, 4, 5]])
>>> np.reshape(np.ravel(a), (2, 3))
array([[0, 1, 2],
[3, 4, 5]])
>>> np.reshape(a, (2, 3), order='F')
array([[0, 4, 3],
[2, 1, 5]])
>>> np.reshape(np.ravel(a, order='F'), (2, 3), order='F')
array([[0, 4, 3],
[2, 1, 5]])