How to keep dimention when selecting a dimention?


I have a dimention=4 Variable out which has the size (100L,64L,32L,32L).
When selecting the second dimension out[:, i, :, :], the shape become (100L, 32L, 32L).
How could I keep the selected dimension as (100L, 1L, 32L, 32L)?


Use out[:, i:i+1, :, :] instead.

1 Like

out.narrow(1, i, 1) might be slightly cleaner.