Colon operator in List Slicing

29 views Asked by At
mini_batch_X = shuffled_X[:, k * mini_batch_size:(k + 1) * mini_batch_size]

What is the semantics of the above line? what does the first colon mean?

1

There are 1 answers

0
Bob On BEST ANSWER

Colon in a slicing operation will generate slice(None, None, None), in numpy it means take all indices for this dimension.

A slice is start:end:step, usually step is omitted writing only start:end, but you can also omit start :end that will slice from beginning, or start: that will end at the last index.