(self, shape, separate_instruments=True, **unused_kwargs)
return mask
Sample a mask.

    Args:
      shape: shape of pianoroll (time, pitch, instrument)
      separate_instruments: whether instruments are separated

    Returns:
      A mask of shape `shape`.
Sample a mask.
Sample a mask .
def __call__(self, shape, separate_instruments=True, **unused_kwargs):
    """Sample a mask.

    Args:
      shape: shape of pianoroll (time, pitch, instrument)
      separate_instruments: whether instruments are separated

    Returns:
      A mask of shape `shape`.
    """
    tt, pp, ii = shape

    if separate_instruments:
      d = tt * ii
    else:
      assert ii == 1
      d = tt * pp
    # sample a mask size
    k = np.random.choice(d) + 1
    # sample a mask of size k
    i = np.random.choice(d, size=k, replace=False)

    mask = np.zeros(d, dtype=np.float32)
    mask[i] = 1.
    if separate_instruments:
      mask = mask.reshape((tt, 1, ii))
      mask = np.tile(mask, [1, pp, 1])
    else:
      mask = mask.reshape((tt, pp, 1))
    return mask
def __call__ ( self , shape , separate_instruments = True , * * unused_kwargs ) : tt , pp , ii = shape if separate_instruments : d = tt * ii else : assert ii == 1 d = tt * pp # sample a mask size k = np . random . choice ( d ) + 1 # sample a mask of size k i = np . random . choice ( d , size = k , replace = False ) mask = np . zeros ( d , dtype = np . float32 ) mask [ i ] = 1. if separate_instruments : mask = mask . reshape ( ( tt , 1 , ii ) ) mask = np . tile ( mask , [ 1 , pp , 1 ] ) else : mask = mask . reshape ( ( tt , pp , 1 ) ) return mask