27185a3ca428d1298811a6c048870d992c05a0d4,opennmt/utils/decoding.py,,_gather_from_word_indices,#Any#Any#,544

Before Change


def _gather_from_word_indices(tensor, indices):
  Index the depth dim of a 2D tensor.
  output_shape = misc.shape_list(indices)
  batch_size = tf.shape(tensor)[0]
  num_indices = tf.size(indices) // batch_size
  batch_pos = tf.range(batch_size * num_indices) // num_indices
  tensor = tf.gather_nd(tensor, tf.stack([batch_pos, tf.reshape(indices, [-1])], axis=-1))
  tensor = tf.reshape(tensor, output_shape)
  return tensor

def _lengths_from_ids(ids, end_id):
  Compute sequence lengths from word ids.
  lengths = tf.not_equal(ids, end_id)

After Change



def _gather_from_word_indices(tensor, indices):
  Index the depth dim of a 2D tensor.
  return tf.gather(tensor, indices, axis=-1, batch_dims=1)

def _lengths_from_ids(ids, end_id):
  Compute sequence lengths from word ids.
  lengths = tf.not_equal(ids, end_id)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: OpenNMT/OpenNMT-tf
Commit Name: 27185a3ca428d1298811a6c048870d992c05a0d4
Time: 2020-03-06
Author: guillaumekln@users.noreply.github.com
File Name: opennmt/utils/decoding.py
Class Name:
Method Name: _gather_from_word_indices


Project Name: jfkirk/tensorrec
Commit Name: db4c8744b0c7fa95502e1172dd4c597e62e55b0e
Time: 2018-02-27
Author: james.f.kirk@gmail.com
File Name: tensorrec/loss_graphs.py
Class Name: WMRBLossGraph
Method Name: loss_graph


Project Name: OpenNMT/OpenNMT-tf
Commit Name: 83ea5808a36de70b86c07bcb02211fd07041532e
Time: 2019-09-03
Author: guillaume.klein@systrangroup.com
File Name: opennmt/models/sequence_to_sequence.py
Class Name:
Method Name: align_tokens_from_attention