(seqs, dtype, depth)
Pads sequences to match the longest and returns as a numpy array.
Pads sequences to match the longest and returns as a numpy array.
Pads sequences to match the longest and returns as a numpy array .
def _maybe_pad_seqs(seqs, dtype, depth):
  """Pads sequences to match the longest and returns as a numpy array."""
  if not len(seqs):  # pylint:disable=g-explicit-length-test,len-as-condition
    return np.zeros((0, 0, depth), dtype)
  lengths = [len(s) for s in seqs]
  if len(set(lengths)) == 1:
    return np.array(seqs, dtype)
  else:
    length = max(lengths)
    return (np.array([np.pad(s, [(0, length - len(s)), (0, 0)], mode='constant')
                      for s in seqs], dtype))
def _maybe_pad_seqs ( seqs , dtype , depth ) : if not len ( seqs ) : # pylint:disable=g-explicit-length-test,len-as-condition return np . zeros ( ( 0 , 0 , depth ) , dtype ) lengths = [ len ( s ) for s in seqs ] if len ( set ( lengths ) ) == 1 : return np . array ( seqs , dtype ) else : length = max ( lengths ) return ( np . array ( [ np . pad ( s , [ ( 0 , length - len ( s ) ) , ( 0 , 0 ) ] , mode = 'constant' ) for s in seqs ] , dtype ) )