# Course 4, week 3

Hey,

I cannot understand this function:
return tf.keras.backend.concatenate([
box_mins[…, 1:2], # y_min
box_mins[…, 0:1], # x_min
box_maxes[…, 1:2], # y_max
box_maxes[…, 0:1] # x_max
])

Probably I do not have some background about lists manipulations like these box_mins[…, 1:2], # y_min.
Could you please give me a link or some explanation?

Best regards,
Gediminas

In Python that operation is called slicing. The ellipsis before the comma means ‘however many dimensions are over here, take them all’. The numbers after the comma mean ‘for this dimension, take a specific range’. The colon ‘i : j’ means start at the i^{th} element and continue to j^{th} non-inclusive. The indices are 0-based.

`box_mins[…,0:1]` means do a slicing operation on the multidimensional object `box_mins`. Note that we don’t know from this anything about the shape other than it has at least 2 dimensions. Specifically, it says to slice one value at the 0^{th} location of the last dimension while maintaining all the other dimensions.

box_mins[…,1:2] means slice one value at the 1^{st} location while retaining all the other dimensions. Remember we’re 0-based indexing.

If the shape of `box_mins` was (7,7,2) then each of these operations would produce an object of shape (7,7,1). Basically splitting apart the `x` and `y` coordinates that had previously been stored as a pair.

After splitting out the max and min x and y values, you then collect them back into a single vector using `concatenate`.

1 Like