def drop(x, keep=0.5):
 if (len(x.shape) == 3):
  if (x.shape[(-1)] == 3):
   img_size = x.shape
   mask = np.random.binomial(n=1, p=keep, size=x.shape[:(-1)])
   for i in range(3):
    x[:, :, i] = np.multiply(x[:, :, i], mask)
  elif (x.shape[(-1)] == 1):
   img_size = x.shape
   x = np.multiply(x, np.random.binomial(n=1, p=keep, size=img_size))
  else:
   raise Exception('Unsupported shape {}'.format(x.shape))
 elif ((len(x.shape) == 2) or 1):
  img_size = x.shape
  x = np.multiply(x, np.random.binomial(n=1, p=keep, size=img_size))
 else:
  raise Exception('Unsupported shape {}'.format(x.shape))
 return x

def drop ( x , keep = 0.5 ) : if ( len ( x . shape ) == 3 ) : if ( x . shape [ ( - 1 ) ] == 3 ) : img_size = x . shape mask = np . random . binomial ( n = 1 , p = keep , size = x . shape [ : ( - 1 ) ] ) for i in range ( 3 ) : x [ : , : , i ] = np . multiply ( x [ : , : , i ] , mask ) elif ( x . shape [ ( - 1 ) ] == 1 ) : img_size = x . shape x = np . multiply ( x , np . random . binomial ( n = 1 , p = keep , size = img_size ) ) else : raise Exception ( 'Unsupported shape {}' . format ( x . shape ) ) elif ( ( len ( x . shape ) == 2 ) or 1 ) : img_size = x . shape x = np . multiply ( x , np . random . binomial ( n = 1 , p = keep , size = img_size ) ) else : raise Exception ( 'Unsupported shape {}' . format ( x . shape ) ) return x
the sequence following the first n elements .