def testAttention1D(self):
     batch = 5
     target_length = 7
     source_length = 13
     source_depth = 9
     target_depth = 11
     attention_size = 21
     output_size = 15
     num_heads = 7
     source = np.random.rand(batch, source_length, source_depth)
     target = np.random.rand(batch, target_length, target_depth)
     mask = np.random.rand(batch, target_length, source_length)
     with self.test_session() as session:
         a = common_layers.attention_1d_v0(
             tf.constant(source, dtype=tf.float32),
             tf.constant(target, dtype=tf.float32), attention_size,
             output_size, num_heads, tf.constant(mask, dtype=tf.float32))
         session.run(tf.global_variables_initializer())
         res = session.run(a)
     self.assertEqual(res.shape, (batch, target_length, output_size))
 def testAttention1D(self):
   batch = 5
   target_length = 7
   source_length = 13
   source_depth = 9
   target_depth = 11
   attention_size = 21
   output_size = 15
   num_heads = 7
   source = np.random.rand(batch, source_length, source_depth)
   target = np.random.rand(batch, target_length, target_depth)
   mask = np.random.rand(batch, target_length, source_length)
   with self.test_session() as session:
     a = common_layers.attention_1d_v0(
         tf.constant(source, dtype=tf.float32),
         tf.constant(target, dtype=tf.float32), attention_size, output_size,
         num_heads, tf.constant(mask, dtype=tf.float32))
     session.run(tf.global_variables_initializer())
     res = session.run(a)
   self.assertEqual(res.shape, (batch, target_length, output_size))