36101ab4095065a4196ff4f6437e94f0d91df4e9,official/nlp/modeling/layers/attention_test.py,CachedAttentionTest,test_masked_attention,#CachedAttentionTest#,201

Before Change


    // one element.
    mask_data = np.random.randint(
        2, size=(batch_size, from_seq_length, from_seq_length))
    masked_output_data, cache = layer([from_data, from_data], mask_data, cache)
    self.assertEqual(masked_output_data.shape, (3, 4, 8))
    self.assertEqual(cache["value"].shape, (3, 4, 2, 2))

    // Tests inputs without cache.
    masked_output_data, cache = layer([from_data, from_data, mask_data])
    self.assertEqual(masked_output_data.shape, (3, 4, 8))
    self.assertIsNone(cache)

  def test_padded_decode(self):

After Change


    layer = attention.CachedAttention(num_heads=num_heads, key_size=head_size)

    // Generate data for the input (non-mask) tensors.
    from_data = tf.zeros((batch_size, from_seq_length, 8), dtype=np.float32)
    // Invoke the data with a random set of mask data. This should mask at least
    // one element.
    mask_data = np.random.randint(
        2, size=(batch_size, from_seq_length, from_seq_length))
    masked_output_data, cache = layer(
        query=from_data, value=from_data, attention_mask=mask_data, cache=cache)
    self.assertEqual(masked_output_data.shape, (3, 4, 8))
    self.assertEqual(cache["value"].shape, (3, 4, 2, 2))

    // Tests inputs without cache.
    masked_output_data, cache = layer(
        query=from_data, value=from_data, attention_mask=mask_data)
    self.assertEqual(masked_output_data.shape, (3, 4, 8))
    self.assertIsNone(cache)

  def test_padded_decode(self):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: tensorflow/models
Commit Name: 36101ab4095065a4196ff4f6437e94f0d91df4e9
Time: 2020-07-21
Author: hongkuny@google.com
File Name: official/nlp/modeling/layers/attention_test.py
Class Name: CachedAttentionTest
Method Name: test_masked_attention


Project Name: stellargraph/stellargraph
Commit Name: d7e12cb9dece9bfc7108d29ddd4614c86ecb70bf
Time: 2020-04-30
Author: Huon.Wilson@data61.csiro.au
File Name: tests/layer/test_sort_pooling.py
Class Name:
Method Name: test_mask


Project Name: tensorflow/models
Commit Name: 570d9a2b06fd6269c930d7fddf38bc60b212ebee
Time: 2020-07-21
Author: hongkuny@google.com
File Name: official/nlp/modeling/layers/attention_test.py
Class Name: CachedAttentionTest
Method Name: test_masked_attention