I want to index into the last axis of a tensor with an arbitrary shape, except for the last which is 2.
e.g. Let x be of the shape (1,2,2). Index to the last axis by
x_0 = x[:, :, 0] # x_0, x_1 shapes are (1,2)
x_1 = x[:, :, 1]
e.g. Let x be of the shape (1,2,3,4,2). Index to the last axis by
x_0 = x[:, :, :, :, 0] # x_0, x_1 shapes are (1,2,3,4)
x_1 = x[:, :, :, :, 1]
I've been unable to find any tensorflow function or usage for slicing an arbitrary shape.
I need a general method to index, such that I can always access the last axis for any shape tensor.