nmt/ion_beam_search_decoder.py
def gather_tree_py(values, parents):
  """Gathers path through a tree backwards from the leave nodes. Used
  to reconstruct beams given their parents."""
  beam_length = values.shape[0]
  num_beams = values.shape[1]
  res = np.zeros_like(values)
  res[-1, :] = values[-1, :]
  for beam_id in range(num_beams):
    parent = parents[-1][beam_id]
    for level in reversed(range(beam_length - 1)):
      res[level, beam_id] = values[level, beam_id][parent]
      parent = parents[level, beam_id][parent]
  return np.array(res).astype(values.dtype)
Gathers path through a tree backwards from the leave nodes. Used
  to reconstruct beams given their parents.
Gathers path through a tree backwards from the leave nodes. Used
to reconstruct beams given their parents.
Gathers path through a tree backwards from the leave nodes . Used to reconstruct beams given their parents .
def gather_tree_py(values, parents):
  beam_length = values.shape[0]
  num_beams = values.shape[1]
  res = np.zeros_like(values)
  res[-1, :] = values[-1, :]
  for beam_id in range(num_beams):
    parent = parents[-1][beam_id]
    for level in reversed(range(beam_length - 1)):
      res[level, beam_id] = values[level, beam_id][parent]
      parent = parents[level, beam_id][parent]
  return np.array(res).astype(values.dtype)
def gather_tree_py ( values , parents ) : beam_length = values . shape [ 0 ] num_beams = values . shape [ 1 ] res = np . zeros_like ( values ) res [ - 1 , : ] = values [ - 1 , : ] for beam_id in range ( num_beams ) : parent = parents [ - 1 ] [ beam_id ] for level in reversed ( range ( beam_length - 1 ) ) : res [ level , beam_id ] = values [ level , beam_id ] [ parent ] parent = parents [ level , beam_id ] [ parent ] return np . array ( res ) . astype ( values . dtype )
Gathers path through a tree backwards from the leave nodes.
Gathers path through a tree backwards from the leave nodes .
"""Gathers path through a tree backwards from the leave nodes. Used
  to reconstruct beams given their parents."""
values
parents