0

Here is the context:

def normal_scale_uncertainty(t, softplus_scale=0.05):
    """Create distribution with variable mean and variance"""
    ts = t[..., :1]
    return tfd.Normal(loc = ts,
                      scale = 1e-3 + tf.math.softplus(softplus_scale * ts))
Paul R
  • 208,748
  • 37
  • 389
  • 560
  • 1
    Does this answer your question? [What does "three dots" in Python mean when indexing what looks like a number?](https://stackoverflow.com/questions/42190783/what-does-three-dots-in-python-mean-when-indexing-what-looks-like-a-number) – Bart Mar 08 '20 at 07:27
  • 1
    Haven't you studied the `tensorflow` docs? Or at least `numpy? – hpaulj Mar 08 '20 at 07:33
  • Bart, I think it is... thanks. – an Kamal Mar 09 '20 at 08:05

1 Answers1

1

Short answer: ... replaces multiple :.

Long answer: let's have a look at an example.

In [20]: d = np.array([[[i + 2*j + 8*k for i in range(5)] for j in range(4)] for k in range(3)])                        

In [21]: d.shape                                                                                                        
Out[21]: (3, 4, 5)

In [22]: d[:, :, 0]                                                                                                     
Out[22]: 
array([[ 0,  2,  4,  6],
       [ 8, 10, 12, 14],
       [16, 18, 20, 22]])

In [23]: d[..., 0]                                                                                                      
Out[23]: 
array([[ 0,  2,  4,  6],
       [ 8, 10, 12, 14],
       [16, 18, 20, 22]])

In [24]: d[:, :, 0] == d[..., 0]                                                                                        
Out[24]: 
array([[ True,  True,  True,  True],
       [ True,  True,  True,  True],
       [ True,  True,  True,  True]])

Can you use d[0, ..., 0] or d[0, ...]? You can. What about d[..., 0, ...]? You'll get an error: IndexError: an index can only have a single ellipsis ('...').

irudyak
  • 2,271
  • 25
  • 20