8eff453c5032faea52c82edd2365371a42643687,opennmt/layers/transformer.py,,build_future_mask,#Any#Any#Any#Any#,47

Before Change


    sequence_length = tile_sequence_length(sequence_length, num_heads)
  if maximum_length is None:
    maximum_length = tf.reduce_max(sequence_length)
  mask = tf.map_fn(
      lambda x: tf.sequence_mask(
          tf.minimum(tf.range(maximum_length) + 1, x),
          maxlen=maximum_length,
          dtype=dtype),
      sequence_length,
      dtype=dtype)
  if num_heads is not None:
    mask = tf.reshape(mask, [-1, num_heads, tf.shape(mask)[1], tf.shape(mask)[2]])
  return mask

After Change


  sequence_mask = tf.sequence_mask(sequence_length, maxlen=maximum_length, dtype=dtype)
  shape = tf.shape(sequence_mask)
  batch_size = shape[0]
  max_time = shape[1]
  mask = tf.ones([batch_size, max_time, max_time], dtype=dtype)
  mask = tf.matrix_band_part(mask, -1, 0)
  mask *= tf.expand_dims(sequence_mask, axis=1)
  if num_heads is not None:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: OpenNMT/OpenNMT-tf
Commit Name: 8eff453c5032faea52c82edd2365371a42643687
Time: 2018-03-27
Author: guillaume.klein@systrangroup.com
File Name: opennmt/layers/transformer.py
Class Name:
Method Name: build_future_mask


Project Name: barisgecer/facegan
Commit Name: 7477c98d5915e679f86b0fc18a443f51724a9fd8
Time: 2018-02-19
Author: b.gecer@imperial.ac.uk
File Name: trainer.py
Class Name: Trainer
Method Name: build_model


Project Name: stellargraph/stellargraph
Commit Name: 411a3896f638406e96cf19cc2dd8a7ed5b34bd85
Time: 2020-04-14
Author: pantelis.elinas@data61.csiro.au
File Name: stellargraph/layer/sort_pooling.py
Class Name: SortPooling
Method Name: call