0

I have the following code

#feats is a tensorflow tensor with shape [1,13,13,255]
x = feats[..., :2]

so what are these three dots doing? I know that in the second dimension we only take the values of 0 and 1.

relot
  • 651
  • 1
  • 6
  • 18

1 Answers1

1

This is from SciPy Cookbook Indexing:

The ellipsis (three dots) indicates "as many ':' as needed". (Its name for use in index-fiddling code is Ellipsis, and it's not numpy-specific.) This makes it easy to manipulate only one dimension of an array, letting numpy do array-wise operations over the "unwanted" dimensions. You can only really have one ellipsis in any given indexing expression, or else the expression would be ambiguous about how many ':' should be put in each. (In fact, for some reason it is allowed to have something like "C[...,...]"; this is not actually ambiguous.)

Algebra8
  • 1,115
  • 1
  • 10
  • 23
  • 1
    I didn't know that it was called ellipsis and three dots or ... didnt show anything in google. Thanks – relot Nov 08 '19 at 15:03